Author: mdryakhlenkov
Date: 2007-07-12 09:23:15 -0400 (Thu, 12 Jul 2007)
New Revision: 2399
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/parts/OrmShapeEditPart.java
Log:
EXIN-366: Adding elements on the diagram by double-click on fields of classes which have
additional information in mapping files
Add <joined-subclass> representation
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-07-12
11:42:40 UTC (rev 2398)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-12
13:23:15 UTC (rev 2399)
@@ -23,6 +23,7 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
+import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass;
@@ -30,6 +31,7 @@
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;
import org.hibernate.type.EntityType;
@@ -141,10 +143,10 @@
ormShape = new SpecialOrmShape(specialRootClass);
getChildren().add(ormShape);
elements.put(specialRootClass.getClassName(), ormShape);
- } else if (ormElement instanceof SingleTableSubclass) {
+ } else if (ormElement instanceof Subclass) {
ormShape = new OrmShape(ormElement);
getChildren().add(ormShape);
- elements.put(((SingleTableSubclass)ormElement).getEntityName(), ormShape);
+ elements.put(((Subclass)ormElement).getClassName(), ormShape);
}
return ormShape;
}
@@ -183,11 +185,23 @@
RootClass rc = (RootClass)persistentClass;
Iterator iter = rc.getSubclassIterator();
while (iter.hasNext()) {
- SingleTableSubclass singleTableSubclass = (SingleTableSubclass)iter.next();
- OrmShape singleTableSubclassShape =
elements.get(singleTableSubclass.getEntityPersisterClass().getCanonicalName());
- if (singleTableSubclassShape == null) singleTableSubclassShape =
createShape(singleTableSubclass);
- if(!isConnectionExist(singleTableSubclassShape, shape))
- new Connection(singleTableSubclassShape, shape);
+ Object element = iter.next();
+ if (element instanceof Subclass) {
+ Subclass subclass = (Subclass)element;
+ OrmShape subclassShape = elements.get(subclass.getClassName());
+ if (subclassShape == null) subclassShape = createShape(subclass);
+ if (((Subclass)element).isJoinedSubclass()) {
+ Table jcTable = ((Subclass)element).getTable();
+ OrmShape jcTableShape = getOrCreateDatabaseTable(jcTable);
+ createConnections(subclassShape, jcTableShape);
+ if(!isConnectionExist(subclassShape, jcTableShape))
+ new Connection(subclassShape, jcTableShape);
+ } else {
+ createConnections(subclassShape, shape);
+ if(!isConnectionExist(subclassShape, shape))
+ new Connection(subclassShape, shape);
+ }
+ }
}
if (persistentClass.getIdentifier() instanceof Component) {
@@ -204,6 +218,7 @@
}
return classShape;
}
+
private OrmShape getOrCreateDatabaseTable(Table databaseTable){
OrmShape tableShape = null;
if(databaseTable != null) {
@@ -265,9 +280,11 @@
private boolean isConnectionExist(Shape source, Shape target){
Connection conn;
- for(int i=0;i<source.getSourceConnections().size();i++){
- conn = (Connection)source.getSourceConnections().get(i);
- if(conn.getTarget().equals(target)) return true;
+ if (source != null && source.getSourceConnections() != null) {
+ for(int i=0;i<source.getSourceConnections().size();i++){
+ conn = (Connection)source.getSourceConnections().get(i);
+ if(conn.getTarget().equals(target)) return true;
+ }
}
return false;
}
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-07-12
11:42:40 UTC (rev 2398)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-12
13:23:15 UTC (rev 2399)
@@ -21,6 +21,7 @@
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;
public class OrmShape extends ExpandeableShape {
@@ -60,9 +61,10 @@
Iterator iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
- if (field.isComposite()) {
+ if (!field.isComposite()) {
+/* if (field.isComposite()) {
bodyOrmShape = new ExpandeableShape(field);
- } else if (field.getValue().isSimpleValue() &&
!((SimpleValue)field.getValue()).isTypeSpecified()) {
+ } else */if (field.getValue().isSimpleValue() &&
!((SimpleValue)field.getValue()).isTypeSpecified()) {
bodyOrmShape = new Shape(field);
} else if (field.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandeableShape(field);
@@ -72,76 +74,80 @@
bodyOrmShape = new Shape(field);
}
getChildren().add(bodyOrmShape);
-// } else {
-// Component component = (Component)field.getValue();
-// Iterator iter = component.getPropertyIterator();
-// while (iter.hasNext()) {
-// Property property = (Property)iter.next();
-// if (property.getValue().getType().isEntityType()) {
-// bodyOrmShape = new ExpandeableShape(property);
-// } else if (property.getValue().getType().isCollectionType()) {
-// bodyOrmShape = new ComponentShape(property);
-// } else {
-// bodyOrmShape = new Shape(property);
-// }
-// getChildren().add(bodyOrmShape);
-// }
-// }
+ } else {
+ Component component = (Component)field.getValue();
+ Iterator iter = component.getPropertyIterator();
+ while (iter.hasNext()) {
+ Property property = (Property)iter.next();
+ if (property.getValue().getType().isEntityType()) {
+ bodyOrmShape = new ExpandeableShape(property);
+ } else if (property.getValue().getType().isCollectionType()) {
+ bodyOrmShape = new ComponentShape(property);
+ } else {
+ bodyOrmShape = new Shape(property);
+ }
+ getChildren().add(bodyOrmShape);
+ }
+ }
}
- } else if (ormElement instanceof SingleTableSubclass) {
- RootClass rootClass = ((SingleTableSubclass)ormElement).getRootClass();
+ } else if (ormElement instanceof Subclass) {
+ RootClass rootClass = ((Subclass)ormElement).getRootClass();
-// Property identifierProperty = rootClass.getIdentifierProperty();
-// if (identifierProperty != null) {
-// getChildren().add(new Shape(identifierProperty));
-// }
+ Property identifierProperty = rootClass.getIdentifierProperty();
+ if (identifierProperty != null) {
+ getChildren().add(new Shape(identifierProperty));
+ }
-// KeyValue identifier = rootClass.getIdentifier();
-// if (identifier instanceof Component) {
-// Iterator iterator = ((Component)identifier).getPropertyIterator();
-// while (iterator.hasNext()) {
-// Property property = (Property) iterator.next();
-// getChildren().add(new Shape(property));
-// }
-// }
+ KeyValue identifier = rootClass.getIdentifier();
+ if (identifier instanceof Component) {
+ Iterator iterator = ((Component)identifier).getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = (Property) iterator.next();
+ getChildren().add(new Shape(property));
+ }
+ }
-// Iterator iterator = rootClass.getPropertyIterator();
-// while (iterator.hasNext()) {
-// Property field = (Property)iterator.next();
-// if (!field.isComposite()) {
-// 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);
-// } else {
-// Component component = (Component)field.getValue();
-// Iterator iter = component.getPropertyIterator();
-// while (iter.hasNext()) {
-// Property property = (Property)iter.next();
-// if (property.getValue().getType().isEntityType()) {
-// bodyOrmShape = new ExpandeableShape(property);
-// } else if (property.getValue().getType().isCollectionType()) {
-// bodyOrmShape = new ComponentShape(property);
-// } else {
-// bodyOrmShape = new Shape(property);
-// }
-// getChildren().add(bodyOrmShape);
-// }
-// }
-// }
- Iterator iter = ((SingleTableSubclass)ormElement).getPropertyIterator();
+ Iterator iterator = rootClass.getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property field = (Property)iterator.next();
+ if (!field.isComposite()) {
+ 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);
+ } else {
+ Component component = (Component)field.getValue();
+ Iterator iter = component.getPropertyIterator();
+ while (iter.hasNext()) {
+ Property property = (Property)iter.next();
+ if (property.getValue().getType().isEntityType()) {
+ bodyOrmShape = new ExpandeableShape(property);
+ } else if (property.getValue().getType().isCollectionType()) {
+ bodyOrmShape = new ComponentShape(property);
+ } else {
+ bodyOrmShape = new Shape(property);
+ }
+ getChildren().add(bodyOrmShape);
+ }
+ }
+ }
+ Iterator iter = ((Subclass)ormElement).getPropertyIterator();
while (iter.hasNext()) {
Property property = (Property)iter.next();
- if (property.getValue().getType().isEntityType()) {
+ if (!property.isComposite()) {
+ if (property.getValue().getType().isEntityType()) {
+ bodyOrmShape = new ExpandeableShape(property);
+ } else if (property.getValue().getType().isCollectionType()) {
+ bodyOrmShape = new ComponentShape(property);
+ } else {
+ bodyOrmShape = new Shape(property);
+ }
+ } else {
bodyOrmShape = new ExpandeableShape(property);
- } else if (property.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(property);
- } else {
- bodyOrmShape = new Shape(property);
}
getChildren().add(bodyOrmShape);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java 2007-07-12
11:42:40 UTC (rev 2398)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java 2007-07-12
13:23:15 UTC (rev 2399)
@@ -32,6 +32,7 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.veditor.editors.figures.RoundLineBorder;
import org.jboss.tools.hibernate.ui.veditor.editors.figures.TitleFigure;
@@ -55,8 +56,8 @@
} else if (element instanceof Table) {
Table table = (Table)element;
text = table.getSchema() + "." + table.getName();
- } else if (element instanceof SingleTableSubclass) {
- text = ormLabelProvider.getText((SingleTableSubclass)element);
+ } else if (element instanceof Subclass) {
+ text = ormLabelProvider.getText((Subclass)element);
}
label.setText(text);
label.setIcon(ormLabelProvider.getImage(getCastedModel().getOrmElement()));
Show replies by date