Author: dgeraskov
Date: 2012-04-30 09:48:39 -0400 (Mon, 30 Apr 2012)
New Revision: 40638
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.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeDefImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JpaUtil.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java
Log:
https://issues.jboss.org/browse/JBIDE-11364
Provide another message when class hierarchy is inconsistent
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 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -38,6 +38,8 @@
public static final String IMPLEMENT_USER_TYPE_INTERFACE =
"USER_TYPE_INTERFACE"; //$NON-NLS-1$
+ public static final String INCONSISTENT_TYPE_HIERARCHY =
"INCONSISTENT_TYPE_HIERARCHY"; //$NON-NLS-1$
+
public static final String TYPE_CLASS_NOT_FOUND = "TYPE_CLASS_NOT_FOUND";
//$NON-NLS-1$
public static final 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 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2012-04-30
13:48:39 UTC (rev 40638)
@@ -9,6 +9,7 @@
TYPE_CANT_BE_EMPTY=Type could not be empty.
USER_TYPE_INTERFACE = Type class \"{0}\" should implement one of interfaces
\"org.hibernate.type.Type\",\
\"org.hibernate.usertype.UserType\",
\"org.hibernate.usertype.CompositeUserType\",
\"org.hibernate.usertype.UserCollectionType\".
+INCONSISTENT_TYPE_HIERARCHY = Type hierarchy of the type \"{0}\" is
inconsistent
TYPE_CLASS_NOT_FOUND = Type class \"{0}\" could not be found.
NAME_CANT_BE_EMPTY = Name could not be empty.
TYPE_DEF_DUPLICATE_NAME=Duplicate type definition named \"{0}\" defined in this
persistence unit
\ 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/java/JavaTypeDefImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeDefImpl.java 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeDefImpl.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -310,9 +310,13 @@
messages.add(HibernateJpaValidationMessage.buildMessage(
IMessage.HIGH_SEVERITY,TYPE_CLASS_NOT_FOUND, new String[]{typeClass}, this,
this.getTypeClassTextRange(astRoot)));
} else {
- if (!JpaUtil.isTypeImplementsOneOfInterfaces(getJpaProject().getJavaProject(),
lwType,
- JavaTypeDef.POSSIBLE_INTERFACES)){
+ Boolean isImplements =
JpaUtil.isTypeImplementsOneOfInterfaces(getJpaProject().getJavaProject(), lwType,
+ JavaTypeDef.POSSIBLE_INTERFACES);
+ if (isImplements == null){
messages.add(HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,INCONSISTENT_TYPE_HIERARCHY, new String[]{typeClass},
this, this.getTypeClassTextRange(astRoot)));
+ } else if (!isImplements){
+ messages.add(HibernateJpaValidationMessage.buildMessage(
IMessage.HIGH_SEVERITY,IMPLEMENT_USER_TYPE_INTERFACE, new String[]{typeClass},
this, this.getTypeClassTextRange(astRoot)));
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JpaUtil.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JpaUtil.java 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JpaUtil.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -28,11 +28,12 @@
* @param javaProject
* @param type
* @param interfaceName
- * @return <code>true</code> if the type implements interface
interfaceName.
+ * @return <code>true</code> if the type implements interface interfaceName.
Returns null if class hierarchy is inconsistent.
* @throws JavaModelException
*/
- public static boolean isTypeImplementsInterface(IJavaProject javaProject, IType type,
String interfaceName) throws JavaModelException{
+ public static Boolean isTypeImplementsInterface(IJavaProject javaProject, IType type,
String interfaceName) throws JavaModelException{
if (type == null) return false;
+ boolean hasInconsistency = false;
String[] interfaces = type.getSuperInterfaceNames();
List<String> resolvedInterfaceNames = new LinkedList<String>();
for (int i = 0; i < interfaces.length; i++) {
@@ -46,6 +47,8 @@
if (interfaceName.equals(fullName))
return true;
}
+ } else {
+ hasInconsistency = true;
}
}
if (type.getSuperclassName() != null){
@@ -60,6 +63,8 @@
return true;
}
}
+ } else {
+ hasInconsistency = true;
}
}
for (String interface_ : resolvedInterfaceNames) {
@@ -68,16 +73,28 @@
return true;
}
}
- return false;
+ return hasInconsistency ? null : false;
}
- public static boolean isTypeImplementsOneOfInterfaces(IJavaProject javaProject, IType
type, String... interfacesName) throws JavaModelException{
+ /**
+ *
+ * @param javaProject
+ * @param type
+ * @param interfacesName
+ * @return if the type implements one of the interfaces. Returns null if class hierarchy
is inconsistent.
+ * @throws JavaModelException
+ */
+ public static Boolean isTypeImplementsOneOfInterfaces(IJavaProject javaProject, IType
type, String... interfacesName) throws JavaModelException{
+ boolean hasInconsistency = false;
for (String interfaceName : interfacesName) {
- if (isTypeImplementsInterface(javaProject, type, interfaceName)){
+ Boolean implementsThis = isTypeImplementsInterface(javaProject, type, interfaceName);
+ if (implementsThis == null ){
+ hasInconsistency = true;
+ } else if (implementsThis == true){
return true;
}
}
- return false;
+ return hasInconsistency ? null : false;
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -148,9 +148,13 @@
messages.add(HibernateJpaValidationMessage.buildMessage(
IMessage.HIGH_SEVERITY,TYPE_CLASS_NOT_FOUND, new String[]{type}, this, range));
} else {
- if (!JpaUtil.isTypeImplementsOneOfInterfaces(getJpaProject().getJavaProject(),
lwType,
- JavaTypeDef.POSSIBLE_INTERFACES)){
+ Boolean isImplements =
JpaUtil.isTypeImplementsOneOfInterfaces(getJpaProject().getJavaProject(), lwType,
+ JavaTypeDef.POSSIBLE_INTERFACES);
+ if (isImplements == null){
messages.add(HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,INCONSISTENT_TYPE_HIERARCHY, new String[]{type}, this,
range));
+ } else if (!isImplements){
+ messages.add(HibernateJpaValidationMessage.buildMessage(
IMessage.HIGH_SEVERITY,IMPLEMENT_USER_TYPE_INTERFACE, new String[]{type}, this,
range));
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -33,7 +33,7 @@
* @author Dmitry Geraskov
*
*/
-public class GeneratedAnnotationImpl extends SourceAnnotation<Attribute>
implements
+public class GeneratedAnnotationImpl extends SourceAnnotation implements
GeneratedAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java 2012-04-30
12:56:41 UTC (rev 40637)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java 2012-04-30
13:48:39 UTC (rev 40638)
@@ -63,6 +63,7 @@
prop.put("format", "true"); //$NON-NLS-1$ //$NON-NLS-2$
prop.put("scriptToConsole", "false"); //$NON-NLS-1$
//$NON-NLS-2$
prop.put("exportToDatabase",
Boolean.toString(initPage.isExportToDB()));//$NON-NLS-1$
+ prop.put("haltOnError", "true");//$NON-NLS-1$ //$NON-NLS-2$
wc.setAttribute(HibernateJpaPlatformUi.full_exporter_id + ".properties",
prop); //$NON-NLS-1$
wc.setAttribute(HibernateJpaPlatformUi.full_exporter_id + ".extension_id",
HibernateLaunchConstants.ATTR_PREFIX + "hbm2ddl"); //$NON-NLS-1$ //$NON-NLS-2$