Author: mdryakhlenkov
Date: 2007-07-09 10:46:12 -0400 (Mon, 09 Jul 2007)
New Revision: 2361
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
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/SpecialRootClass.java
Log:
EXIN-366 Adding elements on the diagram by double-click on fields of classes which have
additional information in mapping files
Dislaying identifier class (inner class of RootClass) as separate element of diagram.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-09
14:35:19 UTC (rev 2360)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-09
14:46:12 UTC (rev 2361)
@@ -1,7 +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"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
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-09
14:35:19 UTC (rev 2360)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-09
14:46:12 UTC (rev 2361)
@@ -188,16 +188,18 @@
if(!isConnectionExist(singleTableSubclassShape, shape))
new Connection(singleTableSubclassShape, shape);
}
-// if (persistentClass.getPersistentClassMapping() != null) {
-// Iterator iter
=((IHibernateClassMapping)(persistentClass).getPersistentClassMapping()).getJoinIterator();
-// while ( iter.hasNext() ) {
-// IJoinMapping jm =(IJoinMapping)iter.next();
-// shape = (OrmShape)elements.get(jm.getTable().getName());
-// if(shape == null)
-// shape = getOrCreateDatabaseTable(jm.getTable());
-// createConnections(classShape, shape);
-// }
-// }
+
+ if (persistentClass.getIdentifier() instanceof Component) {
+ Component identifier = (Component)persistentClass.getIdentifier();
+ if (!identifier.getComponentClassName().equals(identifier.getOwner().getClassName()))
{
+ OrmShape componentClassShape = elements.get(identifier.getComponentClassName());
+ if (componentClassShape == null && persistentClass instanceof RootClass) {
+ componentClassShape =
getOrCreateComponentClass(((RootClass)persistentClass).getIdentifierProperty());
+ OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
+ createConnections(componentClassShape, tableShape);
+ }
+ }
+ }
}
return classShape;
}
@@ -223,14 +225,6 @@
// getOrCreatePersistentClass(singleTableSubclass, null);
}
}
-// IPersistentClassMapping persistentClassMappings[] =
databaseTable.getPersistentClassMappings();
-// for (int j = 0; j < persistentClassMappings.length; j++) {
-// if(persistentClassMappings[j].getPersistentClass() != null ) {
-// OrmShape shape =
(OrmShape)elements.get(persistentClassMappings[j].getPersistentClass().getName());
-// if(shape == null)
-// getOrCreatePersistentClass(persistentClassMappings[j].getPersistentClass(),
null);
-// }
-// }
}
}
return tableShape;
@@ -372,20 +366,24 @@
}
}
- private OrmShape getOrCreateComponentClass(Property property) {
+ public OrmShape getOrCreateComponentClass(Property property) {
OrmShape classShape = null;
- Component component = (Component)((Collection)property.getValue()).getElement();
- if (component != null) {
+ if (property.getValue() instanceof Collection) {
+ Component component = (Component)((Collection)property.getValue()).getElement();
+ if (component != null) {
+ classShape = createShape(property);
+ OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() +
"." + component.getTable().getName());
+ if (tableShape == null) tableShape = getOrCreateDatabaseTable(component.getTable());
+ createConnections(classShape, tableShape);
+ if(!isConnectionExist(classShape, tableShape))
+ new Connection(classShape, tableShape);
+ Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
+ OrmShape parentClassShape =
(OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getClassName());
+ if(!isConnectionExist(parentShape, parentClassShape))
+ new Connection(parentShape, parentClassShape);
+ }
+ } else if (property.getValue() instanceof Component) {
classShape = createShape(property);
- OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() +
"." + component.getTable().getName());
- if (tableShape == null) tableShape = getOrCreateDatabaseTable(component.getTable());
- createConnections(classShape, tableShape);
- if(!isConnectionExist(classShape, tableShape))
- new Connection(classShape, tableShape);
- Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
- OrmShape parentClassShape =
(OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getClassName());
- if(!isConnectionExist(parentShape, parentClassShape))
- new Connection(parentShape, parentClassShape);
}
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-07-09
14:35:19 UTC (rev 2360)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-09
14:46:12 UTC (rev 2361)
@@ -47,10 +47,13 @@
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));
+ Component component = (Component)identifier;
+ if (component.isEmbedded()) {
+ Iterator iterator = ((Component)identifier).getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = (Property) iterator.next();
+ getChildren().add(new Shape(property));
+ }
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java 2007-07-09
14:35:19 UTC (rev 2360)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java 2007-07-09
14:46:12 UTC (rev 2361)
@@ -32,22 +32,29 @@
private void generate() {
if (property != null) {
- Collection collection = (Collection)property.getValue();
- Component component = (Component)collection.getElement();
- setClassName(component.getComponentClassName());
- PersistentClass ownerClass = collection.getOwner();
- if (component.getParentProperty() != null) {
- Property property = ownerClass.getProperty(component.getParentProperty());
- if (property == null &&
ownerClass.getIdentifierProperty().getName().equals(component.getParentProperty())) {
- property = ownerClass.getIdentifierProperty();
+ Component component = null;
+ if (property.getValue() instanceof Collection) {
+ Collection collection = (Collection)property.getValue();
+ component = (Component)collection.getElement();
+ } else if (property.getValue() instanceof Component) {
+ component = (Component)property.getValue();
+ }
+ if (component != null) {
+ setClassName(component.getComponentClassName());
+ PersistentClass ownerClass = component.getOwner();
+ if (component.getParentProperty() != null) {
+ Property property = ownerClass.getProperty(component.getParentProperty());
+ if (property == null &&
ownerClass.getIdentifierProperty().getName().equals(component.getParentProperty())) {
+ property = ownerClass.getIdentifierProperty();
+ }
+ if (property != null) parentProperty = ownerClass.getIdentifierProperty();
}
- if (property != null) parentProperty = ownerClass.getIdentifierProperty();
+ Iterator iterator = component.getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = (Property)iterator.next();
+ if (property != null) addProperty(property);
+ }
}
- Iterator iterator = component.getPropertyIterator();
- while (iterator.hasNext()) {
- Property property = (Property)iterator.next();
- if (property != null) addProperty(property);
- }
}
}
Show replies by date