Author: mdryakhlenkov
Date: 2007-08-08 11:41:29 -0400 (Wed, 08 Aug 2007)
New Revision: 2964
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java
Log:
EXIN-413: Incorrect relations between elements of diagram
Exceptions at opening diagram with Array mapping type
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-08-08
15:30:12 UTC (rev 2963)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-08-08
15:41:29 UTC (rev 2964)
@@ -41,6 +41,7 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
@@ -407,8 +408,8 @@
protected void refreshComponentReferences(ComponentShape componentShape) {
OrmShape childShape = null;
Property property = (Property)componentShape.getOrmElement();
- Type valueType = property.getValue().getType();
- if (valueType.isCollectionType()) {
+// Type valueType = property.getValue().getType();
+ if (property.getValue() instanceof Collection) {
Collection collection = (Collection)property.getValue();
Value component = collection.getElement();
if (component instanceof Component) {// valueType.isComponentType()
@@ -437,6 +438,7 @@
} else if (collection.isOneToMany()) {
childShape = getOrCreateAssociationClass(property);
+if (childShape == null) return;
if(!isConnectionExist((Shape)(componentShape.getChildren().get(1)), childShape)){
new Connection((Shape)(componentShape.getChildren().get(1)), childShape);
((Shape)(componentShape.getChildren().get(1))).firePropertyChange(REFRESH, null,
null);
@@ -524,17 +526,18 @@
OrmShape classShape = null;
OneToMany component = (OneToMany)((Collection)property.getValue()).getElement();
if (component != null) {
-// classShape =
(OrmShape)elements.get(component.getAssociatedClass().getEntityName());
- classShape = getOrCreatePersistentClass(component.getAssociatedClass(), null);
- if (classShape == null) classShape = createShape(component.getAssociatedClass());
- OrmShape tableShape =
(OrmShape)elements.get(HibernateUtils.getTableName(component.getAssociatedClass().getTable()));
- if (tableShape == null) tableShape =
getOrCreateDatabaseTable(component.getAssociatedClass().getTable());
- createConnections(classShape, tableShape);
- if(!isConnectionExist(classShape, tableShape)){
- new Connection(classShape, tableShape);
- classShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
+ if (component.getAssociatedClass() instanceof RootClass) {
+ classShape = getOrCreatePersistentClass(component.getAssociatedClass(), null);
+ if (classShape == null) classShape = createShape(component.getAssociatedClass());
+ OrmShape tableShape =
(OrmShape)elements.get(HibernateUtils.getTableName(component.getAssociatedClass().getTable()));
+ if (tableShape == null) tableShape =
getOrCreateDatabaseTable(component.getAssociatedClass().getTable());
+ createConnections(classShape, tableShape);
+ if(!isConnectionExist(classShape, tableShape)){
+ new Connection(classShape, tableShape);
+ classShape.firePropertyChange(REFRESH, null, null);
+ tableShape.firePropertyChange(REFRESH, null, null);
+ }
+ }
}
return classShape;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-08-08
15:30:12 UTC (rev 2963)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-08-08
15:41:29 UTC (rev 2964)
@@ -13,6 +13,7 @@
import java.util.Iterator;
import org.eclipse.draw2d.geometry.Point;
+import org.hibernate.mapping.Array;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -74,10 +75,10 @@
}
if (field.getValue().isSimpleValue() &&
!((SimpleValue)field.getValue()).isTypeSpecified()) {
bodyOrmShape = new Shape(field);
+ } else if (typeIsAccessible && field.getValue() instanceof Collection) {
+ bodyOrmShape = new ComponentShape(field);
} else if (typeIsAccessible && field.getValue().getType().isEntityType())
{
bodyOrmShape = new ExpandeableShape(field);
- } else if (typeIsAccessible &&
field.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
} else {
bodyOrmShape = new Shape(field);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-08-08
15:30:12 UTC (rev 2963)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-08-08
15:41:29 UTC (rev 2964)
@@ -39,14 +39,17 @@
Iterator iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
- if (field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandeableShape(field);
- } else if (field.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
- } else {
- bodyOrmShape = new Shape(field);
+ try {
+ if (field.getValue().getType().isEntityType()) {
+ bodyOrmShape = new ExpandeableShape(field);
+ } else if (field.getValue().getType().isCollectionType()) {
+ bodyOrmShape = new ComponentShape(field);
+ } else {
+ bodyOrmShape = new Shape(field);
+ }
+ getChildren().add(bodyOrmShape);
+ } catch (Exception e) {
}
- getChildren().add(bodyOrmShape);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java 2007-08-08
15:30:12 UTC (rev 2963)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java 2007-08-08
15:41:29 UTC (rev 2964)
@@ -45,14 +45,12 @@
}
public Object visitDatabaseColumn(Column column, Object argument) {
- // update tau 16.03.2005
StringBuffer name = new StringBuffer();
name.append(column.getName());
- //by Nick 22.04.2005
- int length = -1;
+ int length = -1;
int scale = -1;
-
+
// if (!column.isNativeType())
// {
// int typeCode = column.getSqlTypeCode();
@@ -263,10 +261,13 @@
name.append(field.getName());
name.append(BUNDLE.getString("OrmModelNameVisitor.Colon"));
String typeString = null;
- if (field.getType().isEntityType()) {
- typeString = ((EntityType)field.getType()).getAssociatedEntityName();
- } else {
- typeString = field.getType().getReturnedClass().getName();
+ try {
+ if (field.getType().isEntityType()) {
+ typeString = ((EntityType)field.getType()).getAssociatedEntityName();
+ } else {
+ typeString = field.getType().getReturnedClass().getName();
+ }
+ } catch (Exception e) {
}
if (typeString != null) {
name.append(typeString);
Show replies by date