JBoss Tools SVN: r2372 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 12:03:19 -0400 (Tue, 10 Jul 2007)
New Revision: 2372
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
Log:
EXIN-217 for resource that ceased to declare seam components, invoked cleaning out components loaded previously.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-10 15:57:45 UTC (rev 2371)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-10 16:03:19 UTC (rev 2372)
@@ -43,7 +43,10 @@
for (int i = 0; i < FILE_SCANNERS.length; i++) {
IFileScanner scanner = FILE_SCANNERS[i];
if(scanner.isRelevant(f)) {
- if(!scanner.isLikelyComponentSource(f)) return false;
+ if(!scanner.isLikelyComponentSource(f)) {
+ p.pathRemoved(f.getFullPath());
+ return false;
+ }
LoadedDeclarations c = null;
try {
c = scanner.parse(f);
17 years, 5 months
JBoss Tools SVN: r2371 - trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 11:57:45 -0400 (Tue, 10 Jul 2007)
New Revision: 2371
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
EXIN-336
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-07-10 15:47:48 UTC (rev 2370)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-07-10 15:57:45 UTC (rev 2371)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.seam.core.test;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -25,12 +24,12 @@
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.core.SeamCoreBuilder;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
-import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
public class ScannerTest extends TestCase {
TestProjectProvider provider = null;
@@ -56,6 +55,12 @@
} catch (Exception e) {
fail("Interrupted");
}
+ try {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ XJob.waitForJob();
+ } catch (Exception e) {
+ fail("Cannot build");
+ }
ISeamProject seamProject = null;
try {
seamProject = (ISeamProject)project.getNature(SeamProject.NATURE_ID);
@@ -71,34 +76,31 @@
IFileScanner scanner = SeamCoreBuilder.getXMLScanner();
assertTrue("Scanner cannot recognise components.xml", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise components.xml content", scanner.isLikelyComponentSource(f));
- LoadedDeclarations cs = null;
+ ISeamComponentDeclaration[] cs = null;
try {
- cs = scanner.parse(f);
+ cs = scanner.parse(f).getComponents().toArray(new ISeamComponentDeclaration[0]);
} catch (Exception e) {
fail("Error in xml scanner:" + e.getMessage());
}
- assertTrue("Components are not found in components.xml", cs != null && cs.getComponents().size() > 0);
+ assertTrue("Components are not found in components.xml", cs != null && cs.length > 0);
- assertTrue("First component name must be " + "myComponent", "myComponent".equals(cs.getComponents().get(0).getName()));
+ assertTrue("First component name must be " + "myComponent", "myComponent".equals(cs[0].getName()));
//After having tested details of xml scanner now let us check
// that it succeeded in build.
- Set<ISeamComponent> components = seamProject.getComponents();
+ ISeamComponent c = seamProject.getComponent("myComponent");
- assertTrue("Seam builder must put myComponent to project.", components.size() == 1);
+ assertTrue("Seam builder must put myComponent to project.", c != null);
- for (Iterator iterator = components.iterator(); iterator.hasNext();) {
- ISeamComponent c = (ISeamComponent) iterator.next();
- //We have list property in this component
- List<ISeamProperty> prs = c.getProperties("myList");
- assertTrue("Property myList is not found in components.xml", prs.size() == 1);
- ISeamProperty property = prs.get(0);
- Object o = property.getValue();
- assertTrue("Property myList in myComponent must be instanceof java.util.List.", o instanceof List);
- List<?> oList = (List<?>)o;
- assertTrue("Property myList misses value 'value1.", "value1".equals(oList.get(0)));
- }
+ //We have list property in this component
+ List<ISeamProperty> prs = c.getProperties("myList");
+ assertTrue("Property myList is not found in components.xml", prs.size() == 1);
+ ISeamProperty property = prs.get(0);
+ Object o = property.getValue();
+ assertTrue("Property myList in myComponent must be instanceof java.util.List.", o instanceof List);
+ List<?> oList = (List<?>)o;
+ assertTrue("Property myList misses value 'value1.", "value1".equals(oList.get(0)));
}
public void testJavaScanner() {
@@ -122,22 +124,22 @@
IFileScanner scanner = SeamCoreBuilder.getJavaScanner();
assertTrue("Scanner cannot recognise User.java", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise User.java content", scanner.isLikelyComponentSource(f));
- LoadedDeclarations cs = null;
+ ISeamComponentDeclaration[] cs = null;
try {
- cs = scanner.parse(f);
+ cs = scanner.parse(f).getComponents().toArray(new ISeamComponentDeclaration[0]);
} catch (Exception e) {
fail("Error in java scanner:" + e.getMessage());
}
- assertTrue("Components are not found in User.java", cs != null && cs.getComponents().size() > 0);
+ assertTrue("Components are not found in User.java", cs != null && cs.length > 0);
- assertTrue("First component name must be " + "myUser", "myUser".equals(cs.getComponents().get(0).getName()));
+ assertTrue("First component name must be " + "myUser", "myUser".equals(cs[0].getName()));
//After having tested details of java scanner now let us check
//that it succeeded in build.
- Set<ISeamComponent> components = seamProject.getComponents();
+ ISeamComponent c = seamProject.getComponent("myUser");
- assertTrue("Seam builder must put myUser to project.", components.size() == 1);
+ assertTrue("Seam builder must put myUser to project.", c != null);
}
@@ -163,21 +165,22 @@
IFileScanner scanner = SeamCoreBuilder.getLibraryScanner();
assertTrue("Scanner cannot recognise jboss-seam.jar", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise jboss-seam.jar content", scanner.isLikelyComponentSource(f));
- LoadedDeclarations cs = null;
+ ISeamFactory[] cs = null;
+
try {
- cs = scanner.parse(f);
+ cs = scanner.parse(f).getFactories().toArray(new ISeamFactory[0]);
} catch (Exception e) {
fail("Error in library scanner:" + e.getMessage());
}
- assertTrue("Components are not found in jboss-seam.jar", cs != null && cs.getComponents().size() > 0);
+ assertTrue("Factories are not found in jboss-seam.jar", cs != null && cs.length > 0);
boolean hasActor = false;
- for (int i = 0; i < cs.getComponents().size() && !hasActor; i++) {
- if("actor".equals(cs.getComponents().get(0).getName())) hasActor = true;
+ for (int i = 0; i < cs.length && !hasActor; i++) {
+ if("actor".equals(cs[0].getName())) hasActor = true;
}
- assertTrue("Component " + "actor" + " is not found in jboss-seam.jar", hasActor);
+ assertTrue("Factory " + "actor" + " is not found in jboss-seam.jar", hasActor);
try {
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
@@ -190,7 +193,7 @@
* After having tested details of library scanner now let us check
* that it succeeded in build.
*/
- Set<ISeamComponent> components = seamProject.getComponents();
+ Set<ISeamFactory> components = seamProject.getFactoriesByName("actor");
assertTrue("Seam builder must put actor to project.", components.size()==1);
}
17 years, 5 months
JBoss Tools SVN: r2370 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-07-10 11:47:48 -0400 (Tue, 10 Jul 2007)
New Revision: 2370
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ComponentShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
Log:
http://jira.jboss.com/jira/browse/EXIN-367
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ComponentShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ComponentShape.java 2007-07-10 15:41:19 UTC (rev 2369)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ComponentShape.java 2007-07-10 15:47:48 UTC (rev 2370)
@@ -10,20 +10,23 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.veditor.editors.model;
-import java.util.Iterator;
-
-import org.eclipse.draw2d.geometry.Point;
import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Table;
public class ComponentShape extends ExpandeableShape {
public static final String SET_CHILDS_HIDEN = "set childs hiden";
protected boolean childsHiden = true;
+
+ private OrmShape reference=null;
+
+ public void setReference(OrmShape reference){
+ this.reference = reference;
+ }
+
+ public OrmShape getReference(){
+ return reference;
+ }
public ComponentShape(Object ioe) {
super(ioe);
@@ -46,9 +49,15 @@
public void refreshChildsHiden(OrmDiagram ormDiagram) {
childsHiden = !childsHiden;
+
for (int i = 0; i < getChildren().size(); i++)
((Shape)getChildren().get(i)).setHiden(childsHiden);
+
+ if(!childsHiden)
+ ormDiagram.refreshComponentReferences(this);
+ else
+ ormDiagram.hideReferences(this);
+
firePropertyChange(SET_CHILDS_HIDEN, null, new Boolean(childsHiden));
- ormDiagram.refreshComponentReferences(this);
}
}
\ No newline at end of file
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-10 15:41:19 UTC (rev 2369)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-10 15:47:48 UTC (rev 2370)
@@ -18,26 +18,16 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.draw2d.geometry.Point;
import org.hibernate.cfg.Configuration;
-import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.console.KnownConfigurations;
-import org.hibernate.mapping.Bag;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
-import org.hibernate.mapping.Formula;
import org.hibernate.mapping.KeyValue;
-import org.hibernate.mapping.ManyToOne;
-import org.hibernate.mapping.Map;
import org.hibernate.mapping.OneToMany;
-import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Set;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Table;
@@ -45,8 +35,6 @@
import org.hibernate.type.EntityType;
import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.veditor.VisualEditorPlugin;
-import org.jboss.tools.hibernate.ui.veditor.editors.autolayout.IItemInfo;
-import org.jboss.tools.hibernate.ui.veditor.editors.autolayout.ILinkInfo;
public class OrmDiagram extends ModelElement {
@@ -160,6 +148,22 @@
}
return ormShape;
}
+
+ private OrmShape getShape(Object ormElement) {
+ OrmShape ormShape = null;
+ if (ormElement instanceof RootClass) {
+ ormShape = elements.get(((RootClass)ormElement).getClassName());
+ } else if (ormElement instanceof Table) {
+ Table table = (Table)ormElement;
+ ormShape = elements.get(table.getSchema() + "." + table.getName());
+ } else if (ormElement instanceof Property) {
+ SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
+ ormShape = elements.get(specialRootClass.getClassName());
+ } else if (ormElement instanceof SingleTableSubclass) {
+ ormShape = elements.get(((SingleTableSubclass)ormElement).getEntityName());
+ }
+ return ormShape;
+ }
private OrmShape getOrCreatePersistentClass(PersistentClass persistentClass, Table componentClassDatabaseTable){
OrmShape classShape = null;
@@ -317,24 +321,86 @@
}
}
}
-
+
protected Configuration getConfiguration() {
return configuration;
}
+
+ protected void hideReferences(ComponentShape componentShape) {
+ OrmShape reference = componentShape.getReference();
+ if(reference != null){
+ Object element = reference.getOrmElement();
+ if(element instanceof RootClass){
+ RootClass rc = (RootClass)element;
+ Table table = rc.getTable();
+ OrmShape shape = getShape(table);
+ removeLinks(shape);
+ getChildren().remove(shape);
+ elements.remove(shape);
+ }
+ Property property = (Property)componentShape.getOrmElement();
+ Type valueType = property.getValue().getType();
+ if (valueType.isCollectionType()) {
+ Collection collection = (Collection)property.getValue();
+ Value component = collection.getElement();
+ if (component instanceof Component) {
+ } else if (collection.isOneToMany()) {
+ OneToMany comp = (OneToMany)((Collection)property.getValue()).getElement();
+ if (component != null){
+ Shape sh = elements.get(comp.getAssociatedClass().getTable().getSchema() + "." + comp.getAssociatedClass().getTable().getName());
+ removeLinks(sh);
+ elements.remove(comp.getAssociatedClass().getTable().getSchema() + "." + comp.getAssociatedClass().getTable().getName());
+ Shape sh2 = elements.get(comp.getAssociatedClass().getClassName());
+ removeLinks(sh2);
+ elements.remove(comp.getAssociatedClass().getClassName());
+ }
+ } else if (collection.isMap() || collection.isSet()) {
+ getOrCreateDatabaseTable(collection.getCollectionTable());
+ }
+ }
+ removeLinks(reference);
+ getChildren().remove(reference);
+ elements.remove(reference);
+ componentShape.setReference(null);
+ }
+ //setDirty(true);
+ firePropertyChange(REFRESH, null, null);
+ }
+
+ protected void removeLinks(Shape shape){
+ Connection con;
+ for(int i=shape.getSourceConnections().size()-1;i>=0;i--){
+ con = shape.getSourceConnections().get(i);
+ con.getTarget().getTargetConnections().remove(con);
+ shape.getSourceConnections().remove(i);
+ }
+ for(int i=shape.getTargetConnections().size()-1;i>=0;i--){
+ con = shape.getTargetConnections().get(i);
+ con.getSource().getSourceConnections().remove(con);
+ shape.getTargetConnections().remove(i);
+ }
+ for(int i=shape.getChildren().size()-1;i>=0;i--){
+ removeLinks((Shape)shape.getChildren().get(i));
+ }
+ //if(shape.getParent() != null)shape.getParent().getChildren().remove(shape);
+ //elements.remove(shape);
+ }
protected void refreshComponentReferences(ComponentShape componentShape) {
+ OrmShape childShape = null;
Property property = (Property)componentShape.getOrmElement();
Type valueType = property.getValue().getType();
if (valueType.isCollectionType()) {
Collection collection = (Collection)property.getValue();
Value component = collection.getElement();
if (component instanceof Component) {//valueType.isComponentType()
- OrmShape childShape = (OrmShape)elements.get(((Component)component).getComponentClassName());
+ childShape = (OrmShape)elements.get(((Component)component).getComponentClassName());
if(childShape == null) childShape = getOrCreateComponentClass(property);
if(!isConnectionExist((Shape)(componentShape.getChildren().get(1)), childShape))
new Connection((Shape)(componentShape.getChildren().get(1)), childShape);
+
} else if (collection.isOneToMany()) {
- OrmShape childShape = getOrCreateAssociationClass(property);
+ childShape = getOrCreateAssociationClass(property);
if(!isConnectionExist((Shape)(componentShape.getChildren().get(1)), childShape))
new Connection((Shape)(componentShape.getChildren().get(1)), childShape);
OrmShape keyTableShape = getOrCreateDatabaseTable(collection.getKey().getTable());
@@ -344,10 +410,9 @@
Shape keyColumnShape = keyTableShape.getChild(col);
if (keyColumnShape != null && !isConnectionExist((Shape)(componentShape.getChildren().get(0)), keyColumnShape)) new Connection((Shape)(componentShape.getChildren().get(0)), keyColumnShape);
}
+
} else /*if (collection.isMap() || collection.isSet())*/ {
- Table table = collection.getCollectionTable();
- OrmShape childShape = getOrCreateDatabaseTable(table);
-// childShape.getChild(((Shape)componentShape.getChildren().get(0)).getOrmElement());
+ childShape = getOrCreateDatabaseTable(collection.getCollectionTable());
Shape keyShape = childShape.getChild((Column)((DependantValue)((Shape)componentShape.getChildren().get(0)).getOrmElement()).getColumnIterator().next());
if(!isConnectionExist((Shape)componentShape.getChildren().get(0), keyShape))
new Connection((Shape)componentShape.getChildren().get(0), keyShape);
@@ -360,6 +425,7 @@
new Connection((Shape)componentShape.getChildren().get(1), elementShape);
}
}
+ componentShape.setReference(childShape);
setDirty(true);
firePropertyChange(REFRESH, null, null);
}
17 years, 5 months
JBoss Tools SVN: r2369 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 11:41:19 -0400 (Tue, 10 Jul 2007)
New Revision: 2369
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
Log:
EXIN-217 annotated methods in java source merged correctly in incremental build
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -10,14 +10,25 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
+
/**
* Represents Type of Bijected Attribute.
* @author Alexey Kazakov
*/
-public enum BijectedAttributeType {
- IN,
- OUT,
- DATA_BINDER,
- DATA_MODEL_SELECTION,
- DATA_MODEL_SELECTION_INDEX
+public enum BijectedAttributeType implements SeamAnnotations {
+ IN(IN_ANNOTATION_TYPE),
+ OUT(OUT_ANNOTATION_TYPE),
+ DATA_BINDER(DATA_MODEL_ANNOTATION_TYPE),
+ DATA_MODEL_SELECTION(DATA_MODEL_SELECTION_ANNOTATION_TYPE),
+ DATA_MODEL_SELECTION_INDEX(DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE);
+
+ BijectedAttributeType(String annotationType) {
+ this.annotationType = annotationType;
+ }
+
+ String annotationType;
+ public String getAnnotationType() {
+ return annotationType;
+ }
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -21,6 +21,12 @@
public interface ISeamObject {
/**
+ * Returns seam project that contains this object.
+ * @return
+ */
+ public ISeamProject getSeamProject();
+
+ /**
* Returns parent object of seam model.
* @return
*/
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -37,6 +37,12 @@
}
return false;
}
+
+ public boolean isContextVariable() {
+ //TODO which else?
+ return isOfType(BijectedAttributeType.OUT)
+ || isOfType(BijectedAttributeType.DATA_BINDER);
+ }
public void setTypes(BijectedAttributeType[] types) {
this.types = types;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -1,7 +1,9 @@
package org.jboss.tools.seam.internal.core;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.IMember;
@@ -11,6 +13,7 @@
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponentMethod;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
@@ -184,19 +187,115 @@
}
Change children = new Change(this, null, null, null);
- //TODO do real merge and add changes to children
- this.bijectedAttributes = jd.bijectedAttributes;
- for (IBijectedAttribute a: bijectedAttributes) adopt(a);
- this.componentMethods = jd.componentMethods;
- for (ISeamComponentMethod m: componentMethods) adopt(m);
- this.roles = jd.roles;
- for (IRole role: roles) adopt(role);
+ mergeComponentMethods(jd, children);
+ mergeBijected(jd, children);
+ mergeRoles(jd, children);
changes = Change.addChange(changes, children);
return changes;
}
+
+ public void mergeBijected(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, BijectedAttribute> bijectedMap = new HashMap<Object, BijectedAttribute>();
+ for (IBijectedAttribute r: bijectedAttributes) bijectedMap.put(((SeamObject)r).getId(), (BijectedAttribute)r);
+
+ for (IBijectedAttribute r: jd.bijectedAttributes) {
+ BijectedAttribute loaded = (BijectedAttribute)r;
+ BijectedAttribute current = (BijectedAttribute)bijectedMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ bijectedAttributes.add(loaded);
+ ISeamProject p = getSeamProject();
+ if(p != null && loaded.isContextVariable()) {
+ p.getVariables().add(loaded);
+ }
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ boolean wasOut = current.isContextVariable();
+ boolean isOut = loaded.isContextVariable();
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ if(wasOut != isOut) {
+ ISeamProject p = getSeamProject();
+ if(p != null) {
+ if(wasOut) p.getVariables().remove(current);
+ if(isOut) p.getVariables().add(current);
+ }
+ }
+ }
+ }
+
+ for (BijectedAttribute r: bijectedMap.values()) {
+ bijectedAttributes.remove(r);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+ }
+
+ public void mergeRoles(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, Role> roleMap = new HashMap<Object, Role>();
+ for (IRole r: roles) roleMap.put(((SeamObject)r).getId(), (Role)r);
+
+ for (IRole r: jd.roles) {
+ Role loaded = (Role)r;
+ Role current = (Role)roleMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ roles.add(loaded);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().add(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ }
+ }
+
+ for (Role r: roleMap.values()) {
+ roles.remove(r);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+
+ }
+
+ public void mergeComponentMethods(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, SeamComponentMethod> methodsMap = new HashMap<Object, SeamComponentMethod>();
+ for (ISeamComponentMethod r: componentMethods) methodsMap.put(((SeamObject)r).getId(), (SeamComponentMethod)r);
+
+ for (ISeamComponentMethod r: jd.componentMethods) {
+ SeamComponentMethod loaded = (SeamComponentMethod)r;
+ SeamComponentMethod current = (SeamComponentMethod)methodsMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ componentMethods.add(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ }
+ }
+
+ for (SeamComponentMethod r: methodsMap.values()) {
+ componentMethods.remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+
+ }
+
/**
* @see org.jboss.tools.seam.core.ISeamJavaComponentDeclaration#getPrecedence()
*/
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamObject;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.event.Change;
/**
@@ -44,6 +45,10 @@
public SeamObject() {}
+ public ISeamProject getSeamProject() {
+ return parent == null ? null : parent.getSeamProject();
+ }
+
public Object getId() {
return id;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -74,6 +74,10 @@
public IProject getProject() {
return project;
}
+
+ public ISeamProject getSeamProject() {
+ return this;
+ }
public void setProject(IProject project) {
this.project = project;
@@ -177,6 +181,7 @@
List<Change> addedComponents = null;
for (int i = 0; i < components.length; i++) {
SeamComponentDeclaration loaded = (SeamComponentDeclaration)components[i];
+ loaded.setParent(this);
SeamComponentDeclaration current = (SeamComponentDeclaration)currentComponents.remove(loaded.getId());
loaded.setSourcePath(source);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -121,6 +121,7 @@
public boolean visit(FieldDeclaration node) {
currentAnnotatedField = new AnnotatedASTNode<FieldDeclaration>(node);
+ currentAnnotatedNode = currentAnnotatedField;
return true;
}
@@ -140,6 +141,7 @@
public boolean visit(MethodDeclaration node) {
currentAnnotatedMethod = new AnnotatedASTNode<MethodDeclaration>(node);
+ currentAnnotatedNode = currentAnnotatedMethod;
return true;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -11,7 +11,9 @@
package org.jboss.tools.seam.internal.core.scanner.java;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.IField;
@@ -51,6 +53,7 @@
public ComponentBuilder(LoadedDeclarations ds, ASTVisitorImpl visitor) {
+ this.ds = ds;
annotatedType = visitor.annotatedType;
annotatedFields = visitor.annotatedFields;
annotatedMethods = visitor.annotatedMethods;
@@ -127,21 +130,27 @@
void processBijections() {
for (AnnotatedASTNode<MethodDeclaration> n: annotatedMethods) {
- Annotation in = findAnnotation(n, IN_ANNOTATION_TYPE);
- Annotation out = findAnnotation(n, OUT_ANNOTATION_TYPE);
- if(in == null || out == null) continue;
+ Map<BijectedAttributeType, Annotation> as = new HashMap<BijectedAttributeType, Annotation>();
+ List<BijectedAttributeType> types = new ArrayList<BijectedAttributeType>();
+ Annotation main = null;
+ for (int i = 0; i < BijectedAttributeType.values().length; i++) {
+ Annotation a = findAnnotation(n, BijectedAttributeType.values()[i].getAnnotationType());
+ if(a != null) {
+ as.put(BijectedAttributeType.values()[i], a);
+ if(main == null) main = a;
+ types.add(BijectedAttributeType.values()[i]);
+ }
+ }
+ if(as.size() == 0) continue;
+
MethodDeclaration m = n.getNode();
BijectedAttribute att = new BijectedAttribute();
component.addBijectedAttribute(att);
- BijectedAttributeType[] types = (in == null) ? new BijectedAttributeType[]{BijectedAttributeType.OUT}
- : (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
- : new BijectedAttributeType[]{BijectedAttributeType.IN, BijectedAttributeType.OUT};
- att.setTypes(types);
+ att.setTypes(types.toArray(new BijectedAttributeType[0]));
- Annotation a = in != null ? in : out;
- ValueInfo name = ValueInfo.getValueInfo(a, null);
+ ValueInfo name = ValueInfo.getValueInfo(main, null);
if(name == null) {
name = new ValueInfo();
name.value = m.getName().getIdentifier();
@@ -149,7 +158,7 @@
att.setName(name.getValue());
- ValueInfo scope = ValueInfo.getValueInfo(a, "scope");
+ ValueInfo scope = ValueInfo.getValueInfo(main, "scope");
if(scope != null) att.setScopeAsString(scope.getValue());
att.setSourceMember(findMethod(m));
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-10 14:49:00 UTC (rev 2368)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-10 15:41:19 UTC (rev 2369)
@@ -9,7 +9,10 @@
public static String IN_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "In";
public static String OUT_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Out";
-
+ public static String DATA_MODEL_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "datamodel.DataModel";
+ public static String DATA_MODEL_SELECTION_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "datamodel.DataModelSelection";
+ public static String DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "datamodel.DataModelSelectionIndex";
+
public static String CREATE_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Create";
public static String DESTROY_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Destroy";
17 years, 5 months
JBoss Tools SVN: r2368 - in trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping: bytecode and 26 other directories.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-07-10 10:49:00 -0400 (Tue, 10 Jul 2007)
New Revision: 2368
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java
Modified:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml
Log:
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.bytecode">
+
+ <class name="Bean">
+ <id name="someString" type="string">
+ <generator class="assigned"/>
+ </id>
+ <property name="someLong" type="long" column="S_LONG_1" />
+ <property name="someInteger" type="int" column="S_INT_1" />
+ <property name="someDate" type="timestamp" column="S_DATE_1" />
+ <property name="somelong" type="long" column="S_LONG_2" />
+ <property name="someint" type="int" column="S_INT_2" />
+ <property name="someObject" type="serializable" column="S_OBJ_1" />
+ </class>
+
+
+ <class name="ProxyBean" lazy="true">
+ <id name="someString" type="string">
+ <generator class="assigned"/>
+ </id>
+ <property name="someLong" type="long" column="S_LONG_1" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,78 @@
+package mapping.bytecode;
+
+import java.util.Date;
+import java.text.ParseException;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Bean {
+ private String someString;
+ private Long someLong;
+ private Integer someInteger;
+ private Date someDate;
+ private long somelong;
+ private int someint;
+ private Object someObject;
+
+
+ public String getSomeString() {
+ return someString;
+ }
+
+ public void setSomeString(String someString) {
+ this.someString = someString;
+ }
+
+ public Long getSomeLong() {
+ return someLong;
+ }
+
+ public void setSomeLong(Long someLong) {
+ this.someLong = someLong;
+ }
+
+ public Integer getSomeInteger() {
+ return someInteger;
+ }
+
+ public void setSomeInteger(Integer someInteger) {
+ this.someInteger = someInteger;
+ }
+
+ public Date getSomeDate() {
+ return someDate;
+ }
+
+ public void setSomeDate(Date someDate) {
+ this.someDate = someDate;
+ }
+
+ public long getSomelong() {
+ return somelong;
+ }
+
+ public void setSomelong(long somelong) {
+ this.somelong = somelong;
+ }
+
+ public int getSomeint() {
+ return someint;
+ }
+
+ public void setSomeint(int someint) {
+ this.someint = someint;
+ }
+
+ public Object getSomeObject() {
+ return someObject;
+ }
+
+ public void setSomeObject(Object someObject) {
+ this.someObject = someObject;
+ }
+
+ public void throwException() throws ParseException {
+ throw new ParseException( "you asked for it...", 0 );
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,78 @@
+package mapping.bytecode;
+
+import org.hibernate.property.BasicPropertyAccessor;
+import org.hibernate.property.Getter;
+import org.hibernate.property.Setter;
+
+import java.util.Date;
+
+/**
+ * @author Steve Ebersole
+ */
+public class BeanReflectionHelper {
+
+ public static final Object[] TEST_VALUES = new Object[] {
+ "hello", new Long(1), new Integer(1), new Date(), new Long(1), new Integer(1), new Object()
+ };
+
+ private static final String[] getterNames = new String[7];
+ private static final String[] setterNames = new String[7];
+ private static final Class[] types = new Class[7];
+
+ static {
+ BasicPropertyAccessor propertyAccessor = new BasicPropertyAccessor();
+ Getter getter = propertyAccessor.getGetter( Bean.class, "someString" );
+ Setter setter = propertyAccessor.getSetter( Bean.class, "someString" );
+ getterNames[0] = getter.getMethodName();
+ types[0] = getter.getReturnType();
+ setterNames[0] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someLong" );
+ setter = propertyAccessor.getSetter( Bean.class, "someLong" );
+ getterNames[1] = getter.getMethodName();
+ types[1] = getter.getReturnType();
+ setterNames[1] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someInteger" );
+ setter = propertyAccessor.getSetter( Bean.class, "someInteger" );
+ getterNames[2] = getter.getMethodName();
+ types[2] = getter.getReturnType();
+ setterNames[2] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someDate" );
+ setter = propertyAccessor.getSetter( Bean.class, "someDate" );
+ getterNames[3] = getter.getMethodName();
+ types[3] = getter.getReturnType();
+ setterNames[3] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "somelong" );
+ setter = propertyAccessor.getSetter( Bean.class, "somelong" );
+ getterNames[4] = getter.getMethodName();
+ types[4] = getter.getReturnType();
+ setterNames[4] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someint" );
+ setter = propertyAccessor.getSetter( Bean.class, "someint" );
+ getterNames[5] = getter.getMethodName();
+ types[5] = getter.getReturnType();
+ setterNames[5] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someObject" );
+ setter = propertyAccessor.getSetter( Bean.class, "someObject" );
+ getterNames[6] = getter.getMethodName();
+ types[6] = getter.getReturnType();
+ setterNames[6] = setter.getMethodName();
+ }
+
+ public static String[] getGetterNames() {
+ return getterNames;
+ }
+
+ public static String[] getSetterNames() {
+ return setterNames;
+ }
+
+ public static Class[] getTypes() {
+ return types;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,31 @@
+package mapping.bytecode;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Paul
+ * Date: Mar 9, 2007
+ * Time: 11:31:40 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ProxyBean {
+ private String someString;
+ private long someLong;
+
+
+ public String getSomeString() {
+ return someString;
+ }
+
+ public void setSomeString(String someString) {
+ this.someString = someString;
+ }
+
+
+ public long getSomeLong() {
+ return someLong;
+ }
+
+ public void setSomeLong(long someLong) {
+ this.someLong = someLong;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping
+ package="mapping.cache">
+
+ <class name="Item" table="Items">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+ <class name="VersionedItem" table="VersionedItems">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <version name="version" type="long"/>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,31 @@
+//$Id: Item.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.cache;
+
+
+/**
+ * @author Gavin King
+ */
+public class Item {
+ private Long id;
+ private String name;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,16 @@
+package mapping.cache;
+
+/**
+ * @author Steve Ebersole
+ */
+public class VersionedItem extends Item {
+ private Long version;
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="mapping.cascade">
+
+ <class name="Job" table="T_JOB">
+ <id name="id" column="JOB_ID">
+ <generator class="native"/>
+ </id>
+
+ <many-to-one name="batch" class="JobBatch" cascade="none" column="BATCH_ID"/>
+
+ <property name="status" type="int" column="JOB_STATUS" not-null="true"/>
+ <property name="processingInstructions" type="string" column="PI" not-null="true"/>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,53 @@
+// $Id: Job.java 6663 2005-05-03 20:55:31Z steveebersole $
+package mapping.cascade;
+
+/**
+ * Implementation of Job.
+ *
+ * @author Steve Ebersole
+ */
+public class Job {
+ private Long id;
+ private JobBatch batch;
+ private String processingInstructions;
+ private int status;
+
+ /** GCLIB constructor */
+ Job() {}
+
+ protected Job(JobBatch batch) {
+ this.batch = batch;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ /*package*/ void setId(Long id) {
+ this.id = id;
+ }
+
+ public JobBatch getBatch() {
+ return batch;
+ }
+
+ /*package*/ void setBatch(JobBatch batch) {
+ this.batch = batch;
+ }
+
+ public String getProcessingInstructions() {
+ return processingInstructions;
+ }
+
+ public void setProcessingInstructions(String processingInstructions) {
+ this.processingInstructions = processingInstructions;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="mapping.cascade">
+
+ <class name="JobBatch" table="T_JOB_BATCH">
+ <id name="id" column="BATCH_ID">
+ <generator class="native"/>
+ </id>
+
+ <property name="batchDate" type="timestamp" column="BATCH_DATE" not-null="true"/>
+
+ <set name="jobs" inverse="true" fetch="select" lazy="true" cascade="all, refresh">
+ <key column="BATCH_ID"/>
+ <one-to-many class="Job"/>
+ </set>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,54 @@
+// $Id: JobBatch.java 6663 2005-05-03 20:55:31Z steveebersole $
+package mapping.cascade;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Implementation of JobBatch.
+ *
+ * @author Steve Ebersole
+ */
+public class JobBatch {
+ private Long id;
+ private Date batchDate;
+ private Set jobs = new HashSet();
+
+ /** CGLIB constructor */
+ JobBatch() {}
+
+ public JobBatch(Date batchDate) {
+ this.batchDate = batchDate;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getBatchDate() {
+ return batchDate;
+ }
+
+ public void setBatchDate(Date batchDate) {
+ this.batchDate = batchDate;
+ }
+
+ public Set getJobs() {
+ return jobs;
+ }
+
+ public void setJobs(Set jobs) {
+ this.jobs = jobs;
+ }
+
+ public Job createJob() {
+ Job job = new Job( this );
+ jobs.add( job );
+ return job;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to map a collection
+ <key> to one of the primary key columns of an
+ associated child class with a composite key. This
+ is very useful for legacy data!
+
+-->
+
+<hibernate-mapping package="mapping.cid">
+
+ <class name="Customer">
+
+ <id name="customerId"
+ length="10">
+ <generator class="assigned"/>
+ </id>
+
+ <property name="name" not-null="true" length="100"/>
+ <property name="address" not-null="true" length="200"/>
+
+ <list name="orders"
+ inverse="true"
+ cascade="save-update">
+ <key column="customerId"/>
+ <index column="orderNumber"/>
+ <one-to-many class="Order"/>
+ </list>
+
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,73 @@
+//$Id: Customer.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.GregorianCalendar;
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Customer {
+ private String customerId;
+ private String name;
+ private String address;
+ private List orders = new ArrayList();
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the orders.
+ */
+ public List getOrders() {
+ return orders;
+ }
+ /**
+ * @param orders The orders to set.
+ */
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Order generateNewOrder(BigDecimal total) {
+ Order order = new Order(this);
+ order.setOrderDate( new GregorianCalendar() );
+ order.setTotal( total );
+
+ return order;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) composite keys and many-to-one associations on
+ composite keys
+
+ (2) use of insert="false" update="false" on an
+ association mapping, when the foreign key is
+ also part of the primary key
+
+-->
+
+<hibernate-mapping package="mapping.cid">
+
+ <class name="LineItem">
+
+ <composite-id name="id"
+ class="LineItem$Id">
+ <key-property name="customerId" length="10"/>
+ <key-property name="orderNumber"/>
+ <key-property name="productId" length="10"/>
+ </composite-id>
+
+ <property name="quantity"/>
+
+ <many-to-one name="order"
+ insert="false"
+ update="false"
+ not-null="true">
+ <column name="customerId"/>
+ <column name="orderNumber"/>
+ </many-to-one>
+
+ <many-to-one name="product"
+ insert="false"
+ update="false"
+ not-null="true"
+ column="productId"/>
+
+ </class>
+
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,137 @@
+//$Id: LineItem.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class LineItem {
+ public static class Id implements Serializable {
+ private String customerId;
+ private int orderNumber;
+ private String productId;
+
+ public Id(String customerId, int orderNumber, String productId) {
+ this.customerId = customerId;
+ this.orderNumber = orderNumber;
+ this.productId = productId;
+ }
+ public Id() {}
+
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the productId.
+ */
+ public String getProductId() {
+ return productId;
+ }
+ /**
+ * @param productId The productId to set.
+ */
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+ /**
+ * @return Returns the orderNumber.
+ */
+ public int getOrderNumber() {
+ return orderNumber;
+ }
+ /**
+ * @param orderNumber The orderNumber to set.
+ */
+ public void setOrderNumber(int orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+ public int hashCode() {
+ return customerId.hashCode() + orderNumber + productId.hashCode();
+ }
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id that = (Id) other;
+ return that.customerId.equals(this.customerId) &&
+ that.productId.equals(this.productId) &&
+ that.orderNumber == this.orderNumber;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ private Id id = new Id();
+ private int quantity;
+ private Order order;
+ private Product product;
+
+ public LineItem(Order o, Product p) {
+ this.order = o;
+ this.id.orderNumber = o.getId().getOrderNumber();
+ this.id.customerId = o.getId().getCustomerId();
+ this.id.productId = p.getProductId();
+ o.getLineItems().add(this);
+ }
+
+ public LineItem() {}
+
+ /**
+ * @return Returns the order.
+ */
+ public Order getOrder() {
+ return order;
+ }
+ /**
+ * @param order The order to set.
+ */
+ public void setOrder(Order order) {
+ this.order = order;
+ }
+ /**
+ * @return Returns the product.
+ */
+ public Product getProduct() {
+ return product;
+ }
+ /**
+ * @param product The product to set.
+ */
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+ /**
+ * @return Returns the quantity.
+ */
+ public int getQuantity() {
+ return quantity;
+ }
+ /**
+ * @param quantity The quantity to set.
+ */
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Id getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Id id) {
+ this.id = id;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.cid">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) composite keys and one-to-many associations on
+ composite keys
+
+ (2) use of insert="false" update="false" on an
+ association mapping, when the foreign key is
+ also part of the primary key
+
+ (3) use of a derived property which performs a
+ subselect against associated tables
+
+ (4) use of <synchronize/> to ensure that auto-flush
+ works correctly for an entity with a property
+ derived from other tables
+
+
+-->
+
+ <class name="Order" table="CustomerOrder">
+ <synchronize table="LineItem"/>
+ <synchronize table="Product"/>
+
+ <composite-id name="id"
+ class="Order$Id">
+ <key-property name="customerId" length="10"/>
+ <key-property name="orderNumber"/>
+ </composite-id>
+
+ <property name="orderDate"
+ type="calendar_date"
+ not-null="true"/>
+
+ <property name="total"
+ formula="( select sum(li.quantity*p.cost) from LineItem li, Product p where li.productId = p.productId and li.customerId = customerId and li.orderNumber = orderNumber )"/>
+
+ <many-to-one name="customer"
+ column="customerId"
+ insert="false"
+ update="false"
+ not-null="true"/>
+
+ <bag name="lineItems"
+ fetch="join"
+ lazy="false"
+ inverse="true"
+ cascade="save-update">
+ <key>
+ <column name="customerId"/>
+ <column name="orderNumber"/>
+ </key>
+ <one-to-many class="LineItem"/>
+ </bag>
+
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,145 @@
+//$Id: Order.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+
+/**
+ * @author Gavin King
+ */
+public class Order {
+ public static class Id implements Serializable {
+ private String customerId;
+ private int orderNumber;
+
+ public Id(String customerId, int orderNumber) {
+ this.customerId = customerId;
+ this.orderNumber = orderNumber;
+ }
+ public Id() {}
+
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the orderNumber.
+ */
+ public int getOrderNumber() {
+ return orderNumber;
+ }
+ /**
+ * @param orderNumber The orderNumber to set.
+ */
+ public void setOrderNumber(int orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+ public int hashCode() {
+ return customerId.hashCode() + orderNumber;
+ }
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id that = (Id) other;
+ return that.customerId.equals(this.customerId) &&
+ that.orderNumber == this.orderNumber;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ private Id id = new Id();
+ private Calendar orderDate;
+ private Customer customer;
+ private Collection lineItems = new ArrayList();
+ private BigDecimal total;
+
+ public Order(Customer customer) {
+ this.customer = customer;
+ this.id.customerId = customer.getCustomerId();
+ this.id.orderNumber = customer.getOrders().size();
+ customer.getOrders().add(this);
+ }
+
+ public Order() {}
+
+ /**
+ * @return Returns the customer.
+ */
+ public Customer getCustomer() {
+ return customer;
+ }
+ /**
+ * @param customer The customer to set.
+ */
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ /**
+ * @return Returns the lineItems.
+ */
+ public Collection getLineItems() {
+ return lineItems;
+ }
+ /**
+ * @param lineItems The lineItems to set.
+ */
+ public void setLineItems(Collection lineItems) {
+ this.lineItems = lineItems;
+ }
+ /**
+ * @return Returns the orderDate.
+ */
+ public Calendar getOrderDate() {
+ return orderDate;
+ }
+ /**
+ * @param orderDate The orderDate to set.
+ */
+ public void setOrderDate(Calendar orderDate) {
+ this.orderDate = orderDate;
+ }
+ /**
+ * @return Returns the total.
+ */
+ public BigDecimal getTotal() {
+ return total;
+ }
+ /**
+ * @param total The total to set.
+ */
+ public void setTotal(BigDecimal total) {
+ this.total = total;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Id getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Id id) {
+ this.id = id;
+ }
+
+ public LineItem generateLineItem( Product product, int quantity ) {
+ LineItem li = new LineItem( this, product );
+ li.setQuantity( quantity );
+ lineItems.add( li );
+ return li;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.cid">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) use of a derived property which performs a
+ subselect against an associated table
+
+ (2) use of <synchronize/> to ensure that auto-flush
+ works correctly for an entity with a property
+ derived from another table
+
+
+-->
+
+ <class name="Product">
+ <synchronize table="LineItem"/>
+
+ <id name="productId"
+ length="10">
+ <generator class="assigned"/>
+ </id>
+
+ <property name="description"
+ not-null="true"
+ length="200"/>
+ <property name="price" length="3" column="cost"/>
+ <property name="numberAvailable"/>
+
+ <property name="numberOrdered"
+ formula="( select sum(li.quantity) from LineItem li where li.productId = productId )"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,75 @@
+//$Id: Product.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Product {
+ private String productId;
+ private String description;
+ private BigDecimal price;
+ private int numberAvailable;
+ private int numberOrdered;
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ /**
+ * @return Returns the numberAvailable.
+ */
+ public int getNumberAvailable() {
+ return numberAvailable;
+ }
+ /**
+ * @param numberAvailable The numberAvailable to set.
+ */
+ public void setNumberAvailable(int numberAvailable) {
+ this.numberAvailable = numberAvailable;
+ }
+ /**
+ * @return Returns the numberOrdered.
+ */
+ public int getNumberOrdered() {
+ return numberOrdered;
+ }
+ /**
+ * @param numberOrdered The numberOrdered to set.
+ */
+ public void setNumberOrdered(int numberOrdered) {
+ this.numberOrdered = numberOrdered;
+ }
+ /**
+ * @return Returns the productId.
+ */
+ public String getProductId() {
+ return productId;
+ }
+ /**
+ * @param productId The productId to set.
+ */
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+ /**
+ * @return Returns the price.
+ */
+ public BigDecimal getPrice() {
+ return price;
+ }
+ /**
+ * @param price The price to set.
+ */
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,46 @@
+package mapping.collection.bag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class BagOwner {
+ private String name;
+ private BagOwner parent;
+ private List children = new ArrayList();
+
+ public BagOwner() {
+ }
+
+ public BagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BagOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(BagOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="mapping.collection.bag">
+
+ <class name="BagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="BagOwner" cascade="none" />
+
+ <bag name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="BagOwner" />
+ </bag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+package mapping.collection.idbag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class IdbagOwner {
+ private String name;
+ private List children = new ArrayList();
+
+ public IdbagOwner() {
+ }
+
+ public IdbagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="mapping.collection.idbag">
+
+ <class name="IdbagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <idbag name="children" cascade="all" table="idbag_owner_children">
+ <collection-id column="CHILD" type="long">
+ <generator class="increment"/>
+ </collection-id>
+ <key column="PARENT_FK" />
+ <many-to-many column="CHILD_FK" class="IdbagOwner" />
+ </idbag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,46 @@
+package mapping.collection.list;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ListOwner {
+ private String name;
+ private ListOwner parent;
+ private List children = new ArrayList();
+
+ public ListOwner() {
+ }
+
+ public ListOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ListOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(ListOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="mapping.collection.list">
+
+ <class name="ListOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="ListOwner" cascade="none" />
+
+ <list name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <list-index column="LIST_INDEX"/>
+ <one-to-many class="ListOwner" />
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.collection.map;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="mapping.collection.map">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <map name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <map-key type="string" />
+ <one-to-many class="Child" />
+ </map>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME" type="string"/>
+ <many-to-one name="parent" class="Parent" cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,48 @@
+package mapping.collection.map;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Map children = new HashMap();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map getChildren() {
+ return children;
+ }
+
+ public void setChildren(Map children) {
+ this.children = children;
+ }
+
+ public Child addChild(String name) {
+ Child child = new Child( name );
+ addChild( child );
+ return child;
+ }
+
+ public void addChild(Child child) {
+ child.setParent( this );
+ getChildren().put( child.getName(), child );
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+//$Id: Email.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Email {
+ private String address;
+ Email() {}
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String type) {
+ this.address = type;
+ }
+ public Email(String type) {
+ this.address = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Email) ) return false;
+ Email p = (Email) that;
+ return this.address.equals(p.address);
+ }
+ public int hashCode() {
+ return address.hashCode();
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+//$Id: Permission.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Permission {
+ private String type;
+ Permission() {}
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Permission(String type) {
+ this.type = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Permission) ) return false;
+ Permission p = (Permission) that;
+ return this.type.equals(p.type);
+ }
+ public int hashCode() {
+ return type.hashCode();
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,55 @@
+//$Id: User.java 7628 2005-07-24 06:55:01Z oneovthafew $
+package mapping.collection.original;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private List permissions = new ArrayList();
+ private List emailAddresses = new ArrayList();
+ private Map sessionData = new HashMap();
+ private Set sessionAttributeNames = new HashSet();
+
+ User() {}
+ public User(String name) {
+ userName = name;
+ }
+ public List getPermissions() {
+ return permissions;
+ }
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public List getEmailAddresses() {
+ return emailAddresses;
+ }
+ public void setEmailAddresses(List emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+ public Map getSessionData() {
+ return sessionData;
+ }
+ public void setSessionData(Map sessionData) {
+ this.sessionData = sessionData;
+ }
+ public Set getSessionAttributeNames() {
+ return sessionAttributeNames;
+ }
+ public void setSessionAttributeNames(Set sessionAttributeNames) {
+ this.sessionAttributeNames = sessionAttributeNames;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping package="mapping.collection.original">
+
+ <import class="Permission"/>
+
+ <class name="User" table="`Users`">
+ <id name="userName"/>
+ <list name="permissions" lazy="extra">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Permission">
+ <property name="type" column="permissionType"/>
+ </composite-element>
+ </list>
+ <list name="emailAddresses" fetch="join">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Email">
+ <property name="address"/>
+ </composite-element>
+ </list>
+ <map name="sessionData"
+ order-by="lower(`attributeName`) asc"
+ lazy="extra">
+ <key column="userName"/>
+ <map-key column="`attributeName`"
+ type="string"/>
+ <element column="`attributeValue`"
+ type="serializable"
+ not-null="true"/>
+ </map>
+ <set name="sessionAttributeNames"
+ lazy="extra"
+ inverse="true">
+ <key column="userName"/>
+ <element column="`attributeName`"
+ type="string"/>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.collection.set;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="mapping.collection.set">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <set name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="Child" />
+ </set>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME" type="string"/>
+ <many-to-one name="parent" class="Parent" cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+package mapping.collection.set;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Set children = new HashSet();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set children) {
+ this.children = children;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,38 @@
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * todo: describe Employee
+ *
+ * @author Steve Ebersole
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ private Date hireDate;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Date getHireDate() {
+ return hireDate;
+ }
+
+ public void setHireDate(Date hireDate) {
+ this.hireDate = hireDate;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+//$Id: Person.java 11346 2007-03-26 17:24:58Z steve.ebersole(a)jboss.com $
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private String name;
+ private Date dob;
+ private String address;
+ private String currentAddress;
+ private String previousAddress;
+ private int yob;
+ Person() {}
+ public Person(String name, Date dob, String address) {
+ this.name = name;
+ this.dob = dob;
+ this.address = address;
+ this.currentAddress = address;
+ }
+ public int getYob() {
+ return yob;
+ }
+ public void setYob(int age) {
+ this.yob = age;
+ }
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ public Date getDob() {
+ return dob;
+ }
+ public void setDob(Date dob) {
+ this.dob = dob;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getPreviousAddress() {
+ return previousAddress;
+ }
+ public void setPreviousAddress(String previousAddress) {
+ this.previousAddress = previousAddress;
+ }
+ public void changeAddress(String add) {
+ setPreviousAddress( getAddress() );
+ setAddress(add);
+ }
+ public String getCurrentAddress() {
+ return currentAddress;
+ }
+ public void setCurrentAddress(String currentAddress) {
+ this.currentAddress = currentAddress;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+-->
+
+<hibernate-mapping package="mapping.component.basic">
+
+ <class name="User" table="T_USER">
+ <id name="userName"/>
+ <timestamp name="lastModified"/>
+ <property name="password" not-null="true" optimistic-lock="false"/>
+ <component name="person">
+ <property name="name" update="false" not-null="true"/>
+ <property name="dob" update="false" not-null="true"/>
+ <property name="address"/>
+ <property name="previousAddress" insert="false"/>
+ <property name="yob" formula="year(dob)"/>
+ <property name="currentAddress"
+ column="address"
+ insert="false"
+ update="false"/>
+ </component>
+ </class>
+
+ <class name="Employee" table="T_EMP">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="hireDate" type="date" column="HIRE_DATE"/>
+ <component name="person">
+ <property name="name" update="false" not-null="true"/>
+ <property name="dob" update="false" not-null="true"/>
+ </component>
+ </class>
+
+ <query name="userNameIn"><![CDATA[from User where person.name in (:nameList) or userName in (:nameList)]]></query>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,44 @@
+//$Id: User.java 11346 2007-03-26 17:24:58Z steve.ebersole(a)jboss.com $
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private String password;
+ private Person person;
+ private Date lastModified;
+ User() {}
+ public User(String id, String pw, Person person) {
+ this.userName = id;
+ this.password = pw;
+ this.person = person;
+ }
+ public Date getLastModified() {
+ return lastModified;
+ }
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,30 @@
+package mapping.component.cascading.collection;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Definition {
+ private Long id;
+ private Set values = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Set getValues() {
+ return values;
+ }
+
+ public void setValues(Set values) {
+ this.values = values;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,26 @@
+package mapping.component.cascading.collection;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class LocalizedStrings {
+ private Map strings = new HashMap();
+
+ public void addString(Locale locale, String value) {
+ strings.put( locale, value );
+ }
+
+ public String getString(Locale locale) {
+ return ( String ) strings.get( locale );
+ }
+
+ public Map getStringsCopy() {
+ return java.util.Collections.unmodifiableMap( strings );
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.component.cascading.collection">
+
+ <class name="Definition" >
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <set name="values" cascade="all-delete-orphan,merge" lazy="false" inverse="true">
+ <key column="DEF_ID" />
+ <one-to-many class="Value"/>
+ </set>
+ </class>
+
+ <class name="Value" >
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+
+ <many-to-one name="definition" class="Definition" column="DEF_ID"/>
+
+ <component name="localizedStrings" class="LocalizedStrings">
+ <map name="strings" access="field" cascade="persist,merge" lazy="false">
+ <key column="VAL_ID" />
+ <map-key type="locale" column="LOC" />
+ <element type="string" column="STR_VAL" />
+ </map>
+ </component>
+
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,45 @@
+package mapping.component.cascading.collection;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Value {
+ private Long id;
+ private Definition definition;
+ private LocalizedStrings localizedStrings = new LocalizedStrings();
+
+ private Value() {
+ }
+
+ public Value(Definition definition) {
+ this();
+ this.definition = definition;
+ definition.getValues().add( this );
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(Definition definition) {
+ this.definition = definition;
+ }
+
+ public LocalizedStrings getLocalizedStrings() {
+ return localizedStrings;
+ }
+
+ public void setLocalizedStrings(LocalizedStrings localizedStrings) {
+ this.localizedStrings = localizedStrings;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Address {
+ private Long id;
+ private String street1;
+ private String street2;
+ private String city;
+ private String state;
+ private String zipCode;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet1() {
+ return street1;
+ }
+
+ public void setStreet1(String street1) {
+ this.street1 = street1;
+ }
+
+ public String getStreet2() {
+ return street2;
+ }
+
+ public void setStreet2(String street2) {
+ this.street2 = street2;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getZipCode() {
+ return zipCode;
+ }
+
+ public void setZipCode(String zipCode) {
+ this.zipCode = zipCode;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,36 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Document {
+ private Long id;
+ private String location;
+ private User owner;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.component.cascading.toone">
+
+ <class name="Document" table="COMP_CASC_TO1_DOC">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="owner" class="User" cascade="persist,merge,delete"/>
+ </class>
+
+ <class name="User" table="COMP_CASC_TO1_USER">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <component name="personalInfo" class="PersonalInfo">
+ <many-to-one name="homeAddress" class="Address" cascade="persist,merge,delete"/>
+ </component>
+ </class>
+
+ <class name="Address" table="COMP_CASC_TO1_ADDR">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="street1" type="string" column="STREET1" />
+ <property name="street2" type="string" column="STREET2" />
+ <property name="city" type="string" column="CITY" />
+ <property name="state" type="string" column="STATE" />
+ <property name="zipCode" type="string" column="ZIP_CODE" />
+ </class>
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,25 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class PersonalInfo {
+ private Address homeAddress = new Address();
+
+ public PersonalInfo() {
+ }
+
+ public PersonalInfo(Address homeAddress) {
+ this.homeAddress = homeAddress;
+ }
+
+ public Address getHomeAddress() {
+ return homeAddress;
+ }
+
+ public void setHomeAddress(Address homeAddress) {
+ this.homeAddress = homeAddress;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class User {
+ private Long id;
+ private PersonalInfo personalInfo;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public PersonalInfo getPersonalInfo() {
+ return personalInfo;
+ }
+
+ public void setPersonalInfo(PersonalInfo personalInfo) {
+ this.personalInfo = personalInfo;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,60 @@
+//$Id: Child.java 6978 2005-06-01 03:29:27Z oneovthafew $
+package mapping.compositeelement;
+
+/**
+ * @author gavin
+ */
+public class Child {
+ private String name;
+ private String bio;
+ private Parent parent;
+ private int bioLength;
+ Child() {}
+ public Child(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the parent.
+ */
+ public Parent getParent() {
+ return parent;
+ }
+ /**
+ * @param parent The parent to set.
+ */
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+ public String getBio() {
+ return bio;
+ }
+ public void setBio(String bio) {
+ this.bio = bio;
+ }
+ public int hashCode() {
+ return name.hashCode();
+ }
+ public boolean equals(Object other) {
+ Child c = (Child) other;
+ return c.parent.getId().equals(parent.getId())
+ && c.name.equals(name);
+ }
+ public int getBioLength() {
+ return bioLength;
+ }
+ public void setBioLength(Integer bioLength) {
+ this.bioLength = bioLength==null ? 0 : bioLength.intValue();
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping
+ package="mapping.compositeelement">
+
+ <import class="Child"/>
+
+ <class name="Parent">
+ <id name="id"
+ column="parent_id">
+ <generator class="increment"/>
+ </id>
+ <property name="name"/>
+ <set name="children" table="ParentChild">
+ <key column="parent_id"/>
+ <composite-element class="Child">
+ <parent name="parent"/>
+ <property name="name" not-null="true"/>
+ <property name="bio"/>
+ <property name="bioLength" formula="length(bio)"/>
+ </composite-element>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,54 @@
+//$Id: Parent.java 4478 2004-09-02 02:30:28Z oneovthafew $
+package mapping.compositeelement;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author gavin
+ */
+public class Parent {
+ private Long id;
+ private String name;
+ private Collection children = new HashSet();
+ Parent() {}
+ public Parent(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the children.
+ */
+ public Collection getChildren() {
+ return children;
+ }
+ /**
+ * @param children The children to set.
+ */
+ public void setChildren(Collection children) {
+ this.children = children;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,32 @@
+package mapping.connections;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Other {
+ private Long id;
+ private String name;
+
+ public Other() {
+ }
+
+ public Other(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.connections">
+
+ <class name="Silly">
+ <id name="id" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ <many-to-one name="other" class="Other" cascade="all"/>
+ </class>
+
+ <class name="Other">
+ <id name="id" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,51 @@
+// $Id: Silly.java 9595 2006-03-10 18:14:21Z steve.ebersole(a)jboss.com $
+package mapping.connections;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of Silly.
+ *
+ * @author Steve Ebersole
+ */
+public class Silly implements Serializable {
+ private Long id;
+ private String name;
+ private Other other;
+
+ public Silly() {
+ }
+
+ public Silly(String name) {
+ this.name = name;
+ }
+
+ public Silly(String name, Other other) {
+ this.name = name;
+ this.other = other;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Other getOther() {
+ return other;
+ }
+
+ public void setOther(Other other) {
+ this.other = other;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,22 @@
+//$Id: Course.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.criteria;
+
+/**
+ * @author Gavin King
+ */
+public class Course {
+ private String courseCode;
+ private String description;
+ public String getCourseCode() {
+ return courseCode;
+ }
+ public void setCourseCode(String courseCode) {
+ this.courseCode = courseCode;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.criteria">
+
+ <class name="Course">
+ <id name="courseCode">
+ <generator class="assigned"/>
+ </id>
+ <property name="description"/>
+ </class>
+
+ <class name="Student">
+ <id name="studentNumber">
+ <column name="studentId"/>
+ <generator class="assigned"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <set name="enrolments" inverse="true" cascade="delete">
+ <key column="studentId"/>
+ <one-to-many class="Enrolment"/>
+ </set>
+ <many-to-one name="preferredCourse" column="preferredCourseCode"/>
+ </class>
+
+ <class name="Enrolment">
+ <composite-id>
+ <key-property name="studentNumber">
+ <column name="studentId"/>
+ </key-property>
+ <key-property name="courseCode"/>
+ </composite-id>
+ <many-to-one name="student" insert="false" update="false">
+ <column name="studentId"/>
+ </many-to-one>
+ <many-to-one name="course" insert="false" update="false">
+ <column name="courseCode"/>
+ </many-to-one>
+ <property name="semester" not-null="true"/>
+ <property name="year" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+//$Id: Enrolment.java 6970 2005-05-31 20:24:41Z oneovthafew $
+package mapping.criteria;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Enrolment implements Serializable {
+ private Student student;
+ private Course course;
+ private long studentNumber;
+ private String courseCode;
+ private short year;
+ private short semester;
+ public String getCourseCode() {
+ return courseCode;
+ }
+ public void setCourseCode(String courseId) {
+ this.courseCode = courseId;
+ }
+ public long getStudentNumber() {
+ return studentNumber;
+ }
+ public void setStudentNumber(long studentId) {
+ this.studentNumber = studentId;
+ }
+ public Course getCourse() {
+ return course;
+ }
+ public void setCourse(Course course) {
+ this.course = course;
+ }
+ public Student getStudent() {
+ return student;
+ }
+ public void setStudent(Student student) {
+ this.student = student;
+ }
+ public short getSemester() {
+ return semester;
+ }
+ public void setSemester(short semester) {
+ this.semester = semester;
+ }
+ public short getYear() {
+ return year;
+ }
+ public void setYear(short year) {
+ this.year = year;
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof Enrolment) ) return false;
+ Enrolment that = (Enrolment) other;
+ return studentNumber==that.studentNumber &&
+ courseCode.equals(that.courseCode);
+ }
+
+ public int hashCode() {
+ return courseCode.hashCode();
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,47 @@
+//$Id: Student.java 9116 2006-01-23 21:21:01Z steveebersole $
+package mapping.criteria;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class Student {
+ private long studentNumber;
+ private String name;
+ private Course preferredCourse;
+ private Set enrolments = new HashSet();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getStudentNumber() {
+ return studentNumber;
+ }
+
+ public void setStudentNumber(long studentNumber) {
+ this.studentNumber = studentNumber;
+ }
+
+ public Course getPreferredCourse() {
+ return preferredCourse;
+ }
+
+ public void setPreferredCourse(Course preferredCourse) {
+ this.preferredCourse = preferredCourse;
+ }
+
+ public Set getEnrolments() {
+ return enrolments;
+ }
+
+ public void setEnrolments(Set employments) {
+ this.enrolments = employments;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,50 @@
+//$Id: Account.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Account implements Serializable {
+ private String accountId;
+ private Person user;
+ private char type;
+ /**
+ * @return Returns the user.
+ */
+ public Person getUser() {
+ return user;
+ }
+ /**
+ * @param user The user to set.
+ */
+ public void setUser(Person user) {
+ this.user = user;
+ }
+ /**
+ * @return Returns the accountId.
+ */
+ public String getAccountId() {
+ return accountId;
+ }
+ /**
+ * @param accountId The accountId to set.
+ */
+ public void setAccountId(String accountId) {
+ this.accountId = accountId;
+ }
+ /**
+ * @return Returns the type.
+ */
+ public char getType() {
+ return type;
+ }
+ /**
+ * @param type The type to set.
+ */
+ public void setType(char type) {
+ this.type = type;
+ }
+
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,75 @@
+//$Id: Address.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+
+/**
+ * @author gavin
+ */
+public class Address implements Serializable {
+ private Long id;
+ private String address;
+ private String zip;
+ private String country;
+ private Person person;
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the person.
+ */
+ public Person getPerson() {
+ return person;
+ }
+ /**
+ * @param person The person to set.
+ */
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the country.
+ */
+ public String getCountry() {
+ return country;
+ }
+ /**
+ * @param country The country to set.
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+ /**
+ * @return Returns the zip.
+ */
+ public String getZip() {
+ return zip;
+ }
+ /**
+ * @param zip The zip to set.
+ */
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Demonstrates the use of property-ref to map legacy data where
+ foreign keys reference something other than the primary key of
+ the associated entity. Here we show:
+
+ (1) A one-to-one foreign key association (prefer primary key
+ associations)
+
+ (2) A bidirectional one-to-many association on a key that is
+ comprised of several properties of the associated entity
+
+-->
+
+<hibernate-mapping package="mapping.cuk">
+
+ <class name="Person">
+ <id name="id">
+ <generator class="hilo"/>
+ </id>
+ <property name="name" length="100"/>
+ <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/>
+ <set name="accounts" inverse="true">
+ <key property-ref="userIdAndDeleted">
+ <column name="userId"/>
+ <column name="userDeleted"/>
+ </key>
+ <one-to-many class="Account"/>
+ </set>
+ <properties name="userIdAndDeleted" update="false" unique="true">
+ <property name="userId" length="8"/>
+ <property name="deleted"/>
+ </properties>
+
+ </class>
+
+ <class name="Address">
+ <id name="id">
+ <generator class="hilo"/>
+ </id>
+ <property name="address" length="300"/>
+ <property name="zip" length="5"/>
+ <property name="country" length="25"/>
+ <many-to-one name="person" unique="true" not-null="true"/>
+ </class>
+
+ <class name="Account">
+ <id name="accountId" length="32">
+ <generator class="uuid.hex"/>
+ </id>
+ <many-to-one name="user" property-ref="userIdAndDeleted">
+ <column name="userId"/>
+ <column name="userDeleted"/>
+ </many-to-one>
+ <property name="type" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,100 @@
+//$Id: Person.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author gavin
+ */
+public class Person implements Serializable {
+ private Long id;
+ private String name;
+ private Address address;
+ private String userId;
+ private boolean deleted;
+ private Set accounts = new HashSet();
+ /**
+ * @return Returns the userId.
+ */
+ public String getUserId() {
+ return userId;
+ }
+ /**
+ * @param userId The userId to set.
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+ /**
+ * @return Returns the address.
+ */
+ public Address getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the accounts.
+ */
+ public Set getAccounts() {
+ return accounts;
+ }
+ /**
+ * @param accounts The accounts to set.
+ */
+ public void setAccounts(Set accounts) {
+ this.accounts = accounts;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof Person) {
+ Person that = (Person) other;
+ return that.isDeleted() == deleted && that.getUserId().equals(userId);
+ }
+ else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return userId.hashCode();
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+//$Id: MonetoryAmount.java 6234 2005-03-29 03:07:30Z oneovthafew $
+package mapping.cut;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Currency;
+
+/**
+ * @author Gavin King
+ */
+public class MonetoryAmount implements Serializable {
+
+ private BigDecimal amount;
+ private Currency currency;
+
+ public MonetoryAmount(BigDecimal amount, Currency currency) {
+ this.amount = amount;
+ this.currency = currency;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ public Currency getCurrency() {
+ return currency;
+ }
+
+ public void setCurrency(Currency currency) {
+ this.currency = currency;
+ }
+
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,104 @@
+//$Id: MonetoryAmountUserType.java 6235 2005-03-29 03:17:49Z oneovthafew $
+package mapping.cut;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Currency;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.Type;
+import org.hibernate.usertype.CompositeUserType;
+
+/**
+ * @author Gavin King
+ */
+public class MonetoryAmountUserType implements CompositeUserType {
+
+ public String[] getPropertyNames() {
+ return new String[] { "amount", "currency" };
+ }
+
+ public Type[] getPropertyTypes() {
+ return new Type[] { Hibernate.BIG_DECIMAL, Hibernate.CURRENCY };
+ }
+
+ public Object getPropertyValue(Object component, int property) throws HibernateException {
+ MonetoryAmount ma = (MonetoryAmount) component;
+ return property==0 ? (Object) ma.getAmount() : (Object) ma.getCurrency();
+ }
+
+ public void setPropertyValue(Object component, int property, Object value)
+ throws HibernateException {
+ MonetoryAmount ma = (MonetoryAmount) component;
+ if ( property==0 ) {
+ ma.setAmount( (BigDecimal) value );
+ }
+ else {
+ ma.setCurrency( (Currency) value );
+ }
+ }
+
+ public Class returnedClass() {
+ return MonetoryAmount.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ if (x==y) return true;
+ if (x==null || y==null) return false;
+ MonetoryAmount mx = (MonetoryAmount) x;
+ MonetoryAmount my = (MonetoryAmount) y;
+ return mx.getAmount().equals( my.getAmount() ) &&
+ mx.getCurrency().equals( my.getCurrency() );
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return ( (MonetoryAmount) x ).getAmount().hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
+ throws HibernateException, SQLException {
+ BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
+ Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
+ if (amt==null) return null;
+ return new MonetoryAmount(amt, cur);
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ MonetoryAmount ma = (MonetoryAmount) value;
+ BigDecimal amt = ma == null ? null : ma.getAmount();
+ Currency cur = ma == null ? null : ma.getCurrency();
+ Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index);
+ Hibernate.CURRENCY.nullSafeSet(st, cur, index+1);
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ MonetoryAmount ma = (MonetoryAmount) value;
+ return new MonetoryAmount( ma.getAmount(), ma.getCurrency() );
+ }
+
+ public boolean isMutable() {
+ return true;
+ }
+
+ public Serializable disassemble(Object value, SessionImplementor session)
+ throws HibernateException {
+ return (Serializable) deepCopy(value);
+ }
+
+ public Object assemble(Serializable cached, SessionImplementor session, Object owner)
+ throws HibernateException {
+ return deepCopy(cached);
+ }
+
+ public Object replace(Object original, Object target, SessionImplementor session, Object owner)
+ throws HibernateException {
+ return deepCopy(original); //TODO: improve
+ }
+
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Demonstrates the use of a CompositeUserType.
+
+-->
+
+<hibernate-mapping package="mapping.cut">
+
+ <class name="Transaction" table="Trnsctn">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="description" length="100" not-null="true"/>
+ <property name="value" type="money">
+ <column name="amount" not-null="true"/>
+ <column name="currency" not-null="true"/>
+ </property>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+//$Id: Transaction.java 6234 2005-03-29 03:07:30Z oneovthafew $
+package mapping.cut;
+
+/**
+ * @author Gavin King
+ */
+public class Transaction {
+
+ private Long id;
+ private String description;
+ private MonetoryAmount value;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public MonetoryAmount getValue() {
+ return value;
+ }
+
+ public void setValue(MonetoryAmount value) {
+ this.value = value;
+ }
+
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.cut">
+ <typedef name="money" class="org.hibernate.test.cut.MonetoryAmountUserType"/>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml 2007-07-10 14:46:27 UTC (rev 2367)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -4,6 +4,6 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="mapping.declaration.id.composite.v1">
<class name="KeyManyToOneClass" table="CompositeIdMappedClassTable">
- <id name="keyId" column="KeyID" type="integer"/>
+ <id name="keyId" column="KeyID" type="integer"/>
</class>
</hibernate-mapping>
\ No newline at end of file
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.deletetransient;
+
+/**
+ * todo: describe Address
+ *
+ * @author Steve Ebersole
+ */
+public class Address {
+ private Long id;
+ private String info;
+
+ public Address() {
+ }
+
+ public Address(String info) {
+ this.info = info;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public void setInfo(String info) {
+ this.info = info;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+-->
+
+<hibernate-mapping package="mapping.deletetransient">
+
+ <class name="Person" table="T_PERSON">
+ <id name="id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string"/>
+ <set name="addresses" lazy="true" inverse="false" cascade="all">
+ <key column="PERSON_ID"/>
+ <one-to-many class="Address"/>
+ </set>
+ <bag name="friends" lazy="true" inverse="false" cascade="all" table="T_FRIENDS">
+ <key column="FRIEND_ID_1"/>
+ <many-to-many class="Person" column="FRIEND_ID_2"/>
+ </bag>
+ </class>
+
+ <class name="Address" table="T_ADDRESS">
+ <id name="id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="info" type="string"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,57 @@
+package mapping.deletetransient;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * todo: describe Person
+ *
+ * @author Steve Ebersole
+ */
+public class Person {
+ private Long id;
+ private String name;
+ private Set addresses = new HashSet();
+ private Collection friends = new ArrayList();
+
+ public Person() {
+ }
+
+ public Person(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(Set addresses) {
+ this.addresses = addresses;
+ }
+
+ public Collection getFriends() {
+ return friends;
+ }
+
+ public void setFriends(Collection friends) {
+ this.friends = friends;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.dialect.functional.cache" >
+
+ <class name="TestInterSystemsFunctionsClass" table="SQLUser.TestInterSystemsFunctionsClass">
+ <id type="long" column="id_">
+ <generator class="assigned"/>
+ </id>
+ <property name="date" column="date_"/>
+ <property name="date1" column="date1_"/>
+ <property name="date3" column="date3_"/>
+ <property name="dateText" column="dateText_"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,51 @@
+package mapping.dialect.functional.cache;
+
+import java.util.Date;
+
+/**
+ * Entity for testing function support of InterSystems' CacheSQL...
+ *
+ * @author Jonathan Levinson
+ */
+public class TestInterSystemsFunctionsClass {
+ private java.util.Date date3;
+ private java.util.Date date1;
+ private java.util.Date date;
+ private String dateText;
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+ public String getDateText() {
+ return dateText;
+ }
+
+ public void setDateText(String dateText) {
+ this.dateText = dateText;
+ }
+
+
+ public Date getDate1() {
+ return date1;
+ }
+
+ public void setDate1(Date date1) {
+ this.date1 = date1;
+ }
+
+
+ public Date getDate3() {
+ return date3;
+ }
+
+ public void setDate3(Date date3) {
+ this.date3 = date3;
+ }
+
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,11 @@
+//$Id: Address.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+/**
+ * @author Gavin King
+ */
+public class Address {
+ public String address;
+ public String zip;
+ public String country;
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,35 @@
+//$Id: Customer.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+/**
+ * @author Gavin King
+ */
+public class Customer extends Person {
+ private Employee salesperson;
+ private String comments;
+
+ /**
+ * @return Returns the salesperson.
+ */
+ public Employee getSalesperson() {
+ return salesperson;
+ }
+ /**
+ * @param salesperson The salesperson to set.
+ */
+ public void setSalesperson(Employee salesperson) {
+ this.salesperson = salesperson;
+ }
+ /**
+ * @return Returns the comments.
+ */
+ public String getComments() {
+ return comments;
+ }
+ /**
+ * @param comments The comments to set.
+ */
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,49 @@
+//$Id: Employee.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Employee extends Person {
+ private String title;
+ private BigDecimal salary;
+ private Employee manager;
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ /**
+ * @return Returns the manager.
+ */
+ public Employee getManager() {
+ return manager;
+ }
+ /**
+ * @param manager The manager to set.
+ */
+ public void setManager(Employee manager) {
+ this.manager = manager;
+ }
+ /**
+ * @return Returns the salary.
+ */
+ public BigDecimal getSalary() {
+ return salary;
+ }
+ /**
+ * @param salary The salary to set.
+ */
+ public void setSalary(BigDecimal salary) {
+ this.salary = salary;
+ }
+}
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates content-based discrimination for the
+ table-per-hierarchy mapping strategy, using a formula
+ discriminator.
+
+-->
+
+<hibernate-mapping
+ package="mapping.discriminator"
+ default-access="field">
+
+ <class name="Person"
+ discriminator-value="P">
+
+ <id name="id"
+ column="person_id"
+ unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+
+ <discriminator
+ type="character"
+ formula="case when title is not null then 'E' when salesperson is not null then 'C' else 'P' end"/>
+
+ <property name="name"
+ not-null="true"
+ length="80"/>
+
+ <property name="sex"
+ not-null="true"
+ update="false"/>
+
+ <component name="address">
+ <property name="address"/>
+ <property name="zip"/>
+ <property name="country"/>
+ </component>
+
+ <subclass name="Employee"
+ discriminator-value="E">
+ <property name="title"
+ length="20"/>
+ <property name="salary"
+ length="0"/>
+ <many-to-one name="manager"/>
+ </subclass>
+
+ <subclass name="Customer"
+ discriminator-value="C">
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </subclass>
+
+ </class>
+
+
+</hibernate-mapping>
Added: trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java
===================================================================
--- trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java (rev 0)
+++ trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java 2007-07-10 14:49:00 UTC (rev 2368)
@@ -0,0 +1,70 @@
+//$Id: Person.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private long id;
+ private String name;
+ private char sex;
+ private Address address = new Address();
+ /**
+ * @return Returns the address.
+ */
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(String string) {
+ this.address.address = string;
+ }
+
+ public void setZip(String string) {
+ this.address.zip = string;
+ }
+
+ public void setCountry(String string) {
+ this.address.country = string;
+ }
+
+
+ /**
+ * @return Returns the sex.
+ */
+ public char getSex() {
+ return sex;
+ }
+ /**
+ * @param sex The sex to set.
+ */
+ public void setSex(char sex) {
+ this.sex = sex;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the identity.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param identity The identity to set.
+ */
+ public void setName(String identity) {
+ this.name = identity;
+ }
+
+}
17 years, 5 months
JBoss Tools SVN: r2367 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-07-10 10:46:27 -0400 (Tue, 10 Jul 2007)
New Revision: 2367
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.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
Fixing of bugs with adding elements (bag, set, inner classes).
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-10 12:11:33 UTC (rev 2366)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-10 14:46:27 UTC (rev 2367)
@@ -149,12 +149,9 @@
Table table = (Table)ormElement;
elements.put(table.getSchema() + "." + table.getName(), ormShape);
} else if (ormElement instanceof Property) {
-// ormShape = new OrmShape(ormElement);
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
ormShape = new SpecialOrmShape(specialRootClass);
getChildren().add(ormShape);
-// Property property = (Property)ormElement;
-// elements.put(property.getPersistentClass().getEntityName() + "." + property.getName(), ormShape);
elements.put(specialRootClass.getClassName(), ormShape);
} else if (ormElement instanceof SingleTableSubclass) {
ormShape = new OrmShape(ormElement);
@@ -347,8 +344,10 @@
Shape keyColumnShape = keyTableShape.getChild(col);
if (keyColumnShape != null && !isConnectionExist((Shape)(componentShape.getChildren().get(0)), keyColumnShape)) new Connection((Shape)(componentShape.getChildren().get(0)), keyColumnShape);
}
- } else if (collection.isMap() || collection.isSet()) {
- OrmShape childShape = getOrCreateDatabaseTable(collection.getCollectionTable());
+ } else /*if (collection.isMap() || collection.isSet())*/ {
+ Table table = collection.getCollectionTable();
+ OrmShape childShape = getOrCreateDatabaseTable(table);
+// childShape.getChild(((Shape)componentShape.getChildren().get(0)).getOrmElement());
Shape keyShape = childShape.getChild((Column)((DependantValue)((Shape)componentShape.getChildren().get(0)).getOrmElement()).getColumnIterator().next());
if(!isConnectionExist((Shape)componentShape.getChildren().get(0), keyShape))
new Connection((Shape)componentShape.getChildren().get(0), keyShape);
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-10 12:11:33 UTC (rev 2366)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-10 14:46:27 UTC (rev 2367)
@@ -61,7 +61,9 @@
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
if (!field.isComposite()) {
- if (field.getValue().getType().isEntityType()) {
+ if (field.getValue().isSimpleValue() && !((SimpleValue)field.getValue()).isTypeSpecified()) {
+ bodyOrmShape = new Shape(field);
+ } else if (field.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandeableShape(field);
} else if (field.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(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-07-10 12:11:33 UTC (rev 2366)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-07-10 14:46:27 UTC (rev 2367)
@@ -35,7 +35,7 @@
parentShape = bodyOrmShape;
}
- Iterator iterator = (rootClass).getPropertyIterator();
+ Iterator iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
if (field.getValue().getType().isEntityType()) {
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-10 12:11:33 UTC (rev 2366)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java 2007-07-10 14:46:27 UTC (rev 2367)
@@ -43,7 +43,10 @@
setClassName(component.getComponentClassName());
PersistentClass ownerClass = component.getOwner();
if (component.getParentProperty() != null) {
- Property property = ownerClass.getProperty(component.getParentProperty());
+ Property property = null;
+ try {
+ property = ownerClass.getProperty(component.getParentProperty());
+ } catch (Exception e) {}
if (property == null && ownerClass.getIdentifierProperty().getName().equals(component.getParentProperty())) {
property = ownerClass.getIdentifierProperty();
}
17 years, 5 months
JBoss Tools SVN: r2366 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: scanner/java and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 08:11:33 -0400 (Tue, 10 Jul 2007)
New Revision: 2366
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java
Log:
EXIN-217 Roles and bijected attributes added/removed to variables set of seam project.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -12,7 +12,6 @@
import java.util.List;
-import org.eclipse.jdt.core.IMember;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
@@ -27,10 +26,6 @@
public BijectedAttribute() {
}
- public void setMember(IMember javaSource) {
- this.javaSource = javaSource;
- }
-
public BijectedAttributeType[] getTypes() {
return types;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -29,10 +29,6 @@
return (IMethod)javaSource;
}
- public void setMethod(IMethod method) {
- this.javaSource = method;
- }
-
public boolean isAutoCreate() {
return autoCreate;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -14,6 +14,10 @@
public IMember getSourceMember() {
return javaSource;
}
+
+ public void setSourceMember(IMember javaSource) {
+ this.javaSource = javaSource;
+ }
public int getLength() {
if(javaSource == null) return 0;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -12,6 +12,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -101,7 +102,6 @@
public void load() {
if(isStorageResolved) return;
isStorageResolved = true;
- long begin = System.currentTimeMillis();
if(getClassPath().update()) {
getClassPath().process();
}
@@ -117,8 +117,6 @@
SeamResourceVisitor b = new SeamResourceVisitor(this);
b.visit(f);
}
- long end = System.currentTimeMillis();
-// System.out.println("loaded in " + (end - begin));
}
/**
@@ -225,6 +223,8 @@
if(loaded instanceof ISeamJavaComponentDeclaration) {
SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)loaded;
javaDeclarations.put(jd.getClassName(), jd);
+ allVariables.addAll(jd.getBijectedAttributes());
+ allVariables.addAll(jd.getRoles());
Set<ISeamComponent> cs = getComponentsByClass(jd.getClassName());
for (ISeamComponent ci: cs) {
if(ci == c) continue;
@@ -290,8 +290,11 @@
if(ds[i].source.equals(source)) {
c.removeDeclaration(ds[i]);
if(ds[i] instanceof ISeamJavaComponentDeclaration) {
- String className = ((ISeamJavaComponentDeclaration)ds[i]).getClassName();
+ ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)ds[i];
+ String className = jd.getClassName();
javaDeclarations.remove(className);
+ allVariables.removeAll(jd.getBijectedAttributes());
+ allVariables.removeAll(jd.getRoles());
}
changes = Change.addChange(changes, new Change(c, null, ds[i], null));
}
@@ -329,6 +332,19 @@
}
void componentDeclarationsRemoved(Map<Object,ISeamComponentDeclaration> removed) {
+ Collection<ISeamComponentDeclaration> declarations = removed.values();
+ for (ISeamComponentDeclaration declaration: declarations) {
+ if(declaration instanceof ISeamJavaComponentDeclaration) {
+ ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
+ String className = jd.getClassName();
+ if(javaDeclarations.get(className) == jd) {
+ javaDeclarations.remove(className);
+ }
+ allVariables.removeAll(jd.getRoles());
+ allVariables.removeAll(jd.getBijectedAttributes());
+ }
+ }
+
Iterator<SeamComponent> iterator = allComponents.values().iterator();
while(iterator.hasNext()) {
List<Change> changes = null;
@@ -336,12 +352,6 @@
SeamComponentDeclaration[] ds = c.getAllDeclarations().toArray(new SeamComponentDeclaration[0]);
for (int i = 0; i < ds.length; i++) {
if(removed.containsKey(ds[i].getId())) {
- if(ds[i] instanceof ISeamJavaComponentDeclaration) {
- String className = ((ISeamJavaComponentDeclaration)ds[i]).getClassName();
- if(javaDeclarations.get(className) == ds[i]) {
- javaDeclarations.remove(className);
- }
- }
c.removeDeclaration(ds[i]);
changes = Change.addChange(changes, new Change(c, null, ds[i], null));
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -115,7 +115,7 @@
ValueInfo autoCreate = ValueInfo.getValueInfo(a, "autoCreate");
SeamAnnotatedFactory factory = new SeamAnnotatedFactory();
- factory.setMethod(findMethod(m));
+ factory.setSourceMember(findMethod(m));
factory.setName(factoryName);
if(autoCreate != null) factory.setAutoCreate(true);
if(scope != null) {
@@ -152,7 +152,7 @@
ValueInfo scope = ValueInfo.getValueInfo(a, "scope");
if(scope != null) att.setScopeAsString(scope.getValue());
- att.setMember(findMethod(m));
+ att.setSourceMember(findMethod(m));
}
}
@@ -194,11 +194,12 @@
void createRole(Annotation role) {
Role r = new Role();
r.setSourcePath(component.getSourcePath());
- r.setId(component.getSourceMember());
+ r.setSourceMember(component.getSourceMember());
ValueInfo name = ValueInfo.getValueInfo(role, "name");
if(name == null) return;
+ r.setId("" + component.getName() + ":" + name.getValue());
r.setName(name);
ValueInfo scope = ValueInfo.getValueInfo(role, "scope");
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -176,7 +176,7 @@
IMethod im = findIMethod(component, m);
factory.setId(im);
- factory.setMethod(im);
+ factory.setSourceMember(im);
factory.setName(name);
Object scope = getValue(a, "scope");
@@ -206,7 +206,7 @@
if(scope != null) att.setScopeAsString(scope.toString());
IMember im = findIMember(component, m);
- att.setMember(im);
+ att.setSourceMember(im);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -81,6 +81,7 @@
public boolean isLikelyComponentSource(XModelObject o) {
if(o == null) return false;
+ if(o.getChildByPath("seam.properties") != null) return true;
if(o.getChildByPath("META-INF/seam.properties") != null) return true;
if(o.getChildByPath("META-INF/components.xml") != null) return true;
return false;
@@ -90,6 +91,7 @@
if(o == null) return null;
sourcePath = path;
XModelObject seamProperties = o.getChildByPath("META-INF/seam.properties");
+ if(seamProperties == null) seamProperties = o.getChildByPath("seam.properties");
XModelObject componentsXML = o.getChildByPath("META-INF/components.xml");
if(componentsXML == null && seamProperties == null) return null;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java 2007-07-10 11:00:39 UTC (rev 2365)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java 2007-07-10 12:11:33 UTC (rev 2366)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.validation;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -20,8 +19,8 @@
public ISeamProject getSeamProject() {
ISeamProject project = null;
try {
- project = (ISeamProject)getProject().getNature(ISeamProject.NATURE_ID);
- } catch (CoreException e) {
+ project = SeamCorePlugin.getSeamProject(getProject());
+ } catch (Exception e) {
SeamCorePlugin.getDefault().logError("Can't get Seam Project", e);
}
return project;
17 years, 5 months
JBoss Tools SVN: r2365 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 07:00:39 -0400 (Tue, 10 Jul 2007)
New Revision: 2365
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
EXIN-217 getScope implemented for seam component
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2007-07-10 10:52:37 UTC (rev 2364)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2007-07-10 11:00:39 UTC (rev 2365)
@@ -21,6 +21,12 @@
public static final int DEFAULT_PRECEDENCE = SeamComponentPrecedenceType.APPLICATION;
/**
+ *
+ * @return scope
+ */
+ public ScopeType getScope();
+
+ /**
* @return qualified class name
*/
public String getClassName();
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-10 10:52:37 UTC (rev 2364)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-10 11:00:39 UTC (rev 2365)
@@ -134,8 +134,21 @@
* @see org.jboss.tools.seam.core.ISeamContextVariable#getScope()
*/
public ScopeType getScope() {
- //TODO
- return null;
+ ScopeType scopeType = null;
+ for (ISeamXmlComponentDeclaration d: xmlDeclarations) {
+ String s = d.getScopeAsString();
+ if(s != null && s.length() > 0) {
+ scopeType = d.getScope();
+ }
+ if(scopeType != null && scopeType != ScopeType.UNSPECIFIED) break;
+ }
+ if(scopeType == null || scopeType == ScopeType.UNSPECIFIED) {
+ ISeamJavaComponentDeclaration java = getJavaDeclaration();
+ if(java != null) scopeType = java.getScope();
+ }
+ if(scopeType == null) scopeType = ScopeType.UNSPECIFIED;
+
+ return scopeType;
}
/**
@@ -201,7 +214,7 @@
if(allDeclarations.contains(declaration)) return;
allDeclarations.add(declaration);
if(name.equals(declaration.getName())) {
- ((SeamObject)declaration).setParent(this);
+ adopt(declaration);
}
if(declaration instanceof ISeamJavaComponentDeclaration) {
javaDeclarations.add((ISeamJavaComponentDeclaration)declaration);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10 10:52:37 UTC (rev 2364)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10 11:00:39 UTC (rev 2365)
@@ -78,6 +78,9 @@
if(source != null) {
resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
}
+ if(resource == null && parent != null) {
+ return parent.getResource();
+ }
return resource;
}
@@ -107,6 +110,7 @@
public List<Change> merge(SeamObject s) {
source = s.source;
id = s.id;
+ resource = s.resource;
return null;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 10:52:37 UTC (rev 2364)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 11:00:39 UTC (rev 2365)
@@ -118,7 +118,7 @@
b.visit(f);
}
long end = System.currentTimeMillis();
- System.out.println("loaded in " + (end - begin));
+// System.out.println("loaded in " + (end - begin));
}
/**
17 years, 5 months
JBoss Tools SVN: r2364 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-07-10 06:52:37 -0400 (Tue, 10 Jul 2007)
New Revision: 2364
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
Log:
http://jira.jboss.com/jira/browse/EXIN-327
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-10 10:37:43 UTC (rev 2363)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-10 10:52:37 UTC (rev 2364)
@@ -169,20 +169,20 @@
// Mark nonunique name.
if(!markedDeclarations.contains(checkedDeclaration)) {
// Mark first wrong declaration with that name
- ISeamTextSourceReference target = ((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, target, NONUNIQUE_NAME_MESSAGE_GROUP);
+ IResource checkedDeclarationResource = checkedDeclaration.getResource();
+ ISeamTextSourceReference location = ((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, location, checkedDeclarationResource, NONUNIQUE_NAME_MESSAGE_GROUP);
markedDeclarations.add(checkedDeclaration);
- validationContext.addLinkedResource(checkedDeclaration.getName(), checkedDeclaration.getResource().getLocation());
+ validationContext.addLinkedResource(checkedDeclaration.getName(), checkedDeclarationResource.getLocation());
}
// Mark next wrong declaration with that name
markedDeclarations.add(javaDeclaration);
validationContext.addLinkedResource(javaDeclaration.getName(), javaDeclaration.getResource().getLocation());
- ISeamTextSourceReference target = ((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, target, NONUNIQUE_NAME_MESSAGE_GROUP);
+ ISeamTextSourceReference location = ((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, location, javaDeclarationResource, NONUNIQUE_NAME_MESSAGE_GROUP);
}
}
}
}
}
-
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-10 10:37:43 UTC (rev 2363)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-10 10:52:37 UTC (rev 2364)
@@ -53,15 +53,15 @@
return "org.jboss.tools.seam.internal.core.validation.messages";
}
- protected void addError(String messageId, String[] messageArguments, ISeamTextSourceReference target, String messageGroup) {
- IMessage message = new Message(getBaseName(), IMessage.HIGH_SEVERITY, messageId, messageArguments, target.getResource(), messageGroup);
- message.setLength(target.getLength());
- message.setOffset(target.getStartPosition());
+ protected void addError(String messageId, String[] messageArguments, ISeamTextSourceReference location, IResource target, String messageGroup) {
+ IMessage message = new Message(getBaseName(), IMessage.HIGH_SEVERITY, messageId, messageArguments, target, messageGroup);
+ message.setLength(location.getLength());
+ message.setOffset(location.getStartPosition());
reporter.addMessage(this, message);
}
- protected void addError(String messageId, ISeamTextSourceReference target, String messageGroup) {
- addError(messageId, new String[0], target, messageGroup);
+ protected void addError(String messageId, ISeamTextSourceReference location, IResource target, String messageGroup) {
+ addError(messageId, new String[0], location, target, messageGroup);
}
protected void removeMessagesFromResources(Set<IResource> resources, String messageGroup) {
17 years, 5 months
JBoss Tools SVN: r2363 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-10 06:37:43 -0400 (Tue, 10 Jul 2007)
New Revision: 2363
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamTextSourceReference.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
Log:
EXIN-217 save/load of last build results implemented;
ISeamObject interface added and implemented.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentDeclaration.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentDeclaration.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -14,7 +14,7 @@
* Represents declaration of seam component.
* @author Alexey Kazakov
*/
-public interface ISeamComponentDeclaration extends ISeamTextSourceReference {
+public interface ISeamComponentDeclaration extends ISeamObject, ISeamTextSourceReference {
/**
* @return name of component.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -15,7 +15,7 @@
* This interface represents only methods with types enumerated in SeamComponentMethodType
* @author Alexey Kazakov
*/
-public interface ISeamComponentMethod extends ISeamJavaSourceReference {
+public interface ISeamComponentMethod extends ISeamJavaSourceReference, ISeamObject {
/**
* @return is @ Create method
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -14,7 +14,7 @@
* Represents Seam Context Variable.
* @author Alexey Kazakov
*/
-public interface ISeamContextVariable {
+public interface ISeamContextVariable extends ISeamObject {
/**
* @return name of context variable
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Common interface for objects of seam model.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamObject {
+
+ /**
+ * Returns parent object of seam model.
+ * @return
+ */
+ public ISeamObject getParent();
+
+ /**
+ * Returns path of resource that declares this object.
+ * @return
+ */
+ public IPath getSourcePath();
+
+ /**
+ * Returns resource that declares this object.
+ * @return resource
+ */
+ public IResource getResource();
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -13,11 +13,10 @@
import java.util.Set;
import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
-public interface ISeamProject extends IProjectNature {
+public interface ISeamProject extends IProjectNature, ISeamObject {
public static String NATURE_ID = "org.jboss.tools.seam.core.seam";
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -13,7 +13,7 @@
/**
* A property of Seam Component defined in component.xml or seam.properties files
*/
-public interface ISeamProperty extends ISeamTextSourceReference {
+public interface ISeamProperty extends ISeamObject, ISeamTextSourceReference {
/**
* @return name of this property
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamTextSourceReference.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamTextSourceReference.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamTextSourceReference.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.seam.core;
-import org.eclipse.core.resources.IResource;
-
/**
* An interface of seam tools model object that has text source.
* @author Alexey Kazakov
@@ -19,11 +17,6 @@
public interface ISeamTextSourceReference {
/**
- * @return resource
- */
- public IResource getResource();
-
- /**
* @return start position of element in text
*/
public int getStartPosition();
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -22,15 +22,12 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.seam.internal.core.SeamComponent;
-import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamProject;
+import org.jboss.tools.seam.internal.core.SeamResourceVisitor;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
-import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
import org.jboss.tools.seam.internal.core.scanner.lib.LibraryScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
@@ -43,8 +40,9 @@
new JavaScanner(),
new XMLScanner(),
// new LibraryScanner()
- };
- SampleResourceVisitor RESOURCE_VISITOR = new SampleResourceVisitor();
+ };
+
+ SeamResourceVisitor resourceVisitor = null;
SeamProject getSeamProject() {
IProject p = getProject();
@@ -54,6 +52,14 @@
//TODO
return null;
}
+ }
+
+ SeamResourceVisitor getResourceVisitor() {
+ if(resourceVisitor == null) {
+ SeamProject p = getSeamProject();
+ resourceVisitor = new SeamResourceVisitor(p);
+ }
+ return resourceVisitor;
}
class SampleDeltaVisitor implements IResourceDeltaVisitor {
@@ -64,14 +70,14 @@
IResource resource = delta.getResource();
switch (delta.getKind()) {
case IResourceDelta.ADDED:
- RESOURCE_VISITOR.visit(resource);
+ getResourceVisitor().getVisitor().visit(resource);
break;
case IResourceDelta.REMOVED:
SeamProject p = getSeamProject();
if(p != null) p.pathRemoved(resource.getFullPath());
break;
case IResourceDelta.CHANGED:
- RESOURCE_VISITOR.visit(resource);
+ getResourceVisitor().getVisitor().visit(resource);
break;
}
//return true to continue visiting children.
@@ -79,36 +85,6 @@
}
}
- class SampleResourceVisitor implements IResourceVisitor {
- public boolean visit(IResource resource) {
- if(resource instanceof IFile) {
- IFile f = (IFile)resource;
- for (int i = 0; i < FILE_SCANNERS.length; i++) {
- IFileScanner scanner = FILE_SCANNERS[i];
- if(scanner.isRelevant(f)) {
- if(!scanner.isLikelyComponentSource(f)) return false;
- LoadedDeclarations c = null;
- try {
- c = scanner.parse(f);
- } catch (Exception e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- if(c != null) componentsLoaded(c, f);
- }
- }
- }
- //return true to continue visiting children.
- return true;
- }
- }
-
- void componentsLoaded(LoadedDeclarations c, IFile resource) {
- if(c == null || c.getComponents().size() + c.getFactories().size() == 0) return;
- SeamProject p = getSeamProject();
- if(p == null) return;
- p.registerComponents(c, resource.getFullPath());
- }
-
class XMLErrorHandler extends DefaultHandler {
private IFile file;
@@ -162,9 +138,11 @@
*/
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException {
- if(getSeamProject().getClassPath().update()) {
- System.out.println("update from class path");
- getSeamProject().getClassPath().process();
+ SeamProject sp = getSeamProject();
+ sp.resolveStorage(kind != FULL_BUILD);
+
+ if(sp.getClassPath().update()) {
+ sp.getClassPath().process();
}
if (kind == FULL_BUILD) {
@@ -176,7 +154,8 @@
} else {
incrementalBuild(delta, monitor);
}
- }
+ }
+ sp.store();
return null;
}
@@ -202,7 +181,7 @@
protected void fullBuild(final IProgressMonitor monitor)
throws CoreException {
try {
- getProject().accept(RESOURCE_VISITOR);
+ getProject().accept(getResourceVisitor().getVisitor());
} catch (CoreException e) {
e.printStackTrace();
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
+import org.jboss.tools.seam.internal.core.SeamProject;
import org.osgi.framework.BundleContext;
/**
@@ -76,4 +79,33 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ /**
+ * Factory method creating seam project instance by project resource.
+ * Returns null if
+ * (1) project does not exist
+ * (2) project is closed
+ * (3) project has no seam nature
+ * (4) creating seam project failed.
+ * @param project
+ * @return
+ */
+ public static ISeamProject getSeamProject(IProject project) {
+ if(project == null || !project.exists() || !project.isOpen()) return null;
+ try {
+ if(!project.hasNature(ISeamProject.NATURE_ID)) return null;
+ } catch (CoreException e) {
+ //ignore - all checks are done above
+ return null;
+ }
+ try {
+ SeamProject seamProject = (SeamProject)project.getNature(ISeamProject.NATURE_ID);
+ seamProject.resolveStorage(true);
+ return seamProject;
+ } catch (Exception e) {
+ getPluginLog().logError(e);
+ }
+ return null;
+ }
+
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.seam.internal.core;
import java.util.HashMap;
@@ -6,7 +16,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
@@ -14,41 +23,17 @@
import org.jboss.tools.seam.core.event.Change;
import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
-public class AbstractContextVariable implements ISeamContextVariable, ISeamTextSourceReference {
- /**
- * Path of resource where this factory is declared.
- */
- protected IPath source;
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class AbstractContextVariable extends SeamObject implements ISeamContextVariable, ISeamTextSourceReference {
- protected IResource resource = null;
-
- /**
- * Object that allows to identify this declaration.
- */
- protected Object id;
-
protected String name;
protected ScopeType scopeType;
protected String scope;
protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
- public Object getId() {
- return id;
- }
-
- public void setId(Object id) {
- this.id = id;
- }
-
- public void setSourcePath(IPath path) {
- source = path;
- }
-
- public IPath getSourcePath() {
- return source;
- }
-
public String getName() {
return name;
}
@@ -82,14 +67,6 @@
return 0;
}
- public IResource getResource() {
- if(resource != null) return resource;
- if(source != null) {
- resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
- }
- return resource;
- }
-
public int getStartPosition() {
// TODO Auto-generated method stub
return 0;
@@ -101,12 +78,10 @@
* @param f
* @return list of changes
*/
- public List<Change> merge(AbstractContextVariable f) {
- List<Change> changes = null;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ AbstractContextVariable f = (AbstractContextVariable)s;
- source = f.source;
- id = f.id;
-
if(!stringsEqual(name, f.name)) {
changes = Change.addChange(changes, new Change(this, ISeamXmlComponentDeclaration.NAME, name, f.name));
name = f.name;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -47,8 +47,9 @@
this.types = types;
}
- public List<Change> merge(AbstractContextVariable f) {
- List<Change> changes = super.merge(f);
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ AbstractContextVariable f = (AbstractContextVariable)s;
if(f instanceof BijectedAttribute) {
BijectedAttribute sf = (BijectedAttribute)f;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -10,11 +10,8 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IMethod;
import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
@@ -44,9 +41,9 @@
this.autoCreate = autoCreate;
}
- public List<Change> merge(AbstractContextVariable f) {
- List<Change> changes = super.merge(f);
- SeamAnnotatedFactory af = (SeamAnnotatedFactory)f;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamAnnotatedFactory af = (SeamAnnotatedFactory)s;
if(autoCreate != af.autoCreate) {
changes = Change.addChange(changes, new Change(this, ISeamXmlComponentDeclaration.AUTO_CREATE, autoCreate, af.autoCreate));
@@ -69,10 +66,6 @@
return valueInfo != null ? valueInfo.getLength() : 0;
}
- public IResource getResource() {
- return SeamAnnotatedFactory.this.getResource();
- }
-
public int getStartPosition() {
return valueInfo != null ? valueInfo.getStartPosition() : 0;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -29,7 +29,10 @@
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
-public class SeamComponent implements ISeamComponent {
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamComponent extends SeamObject implements ISeamComponent {
protected String name = null;
@@ -197,6 +200,9 @@
public void addDeclaration(ISeamComponentDeclaration declaration) {
if(allDeclarations.contains(declaration)) return;
allDeclarations.add(declaration);
+ if(name.equals(declaration.getName())) {
+ ((SeamObject)declaration).setParent(this);
+ }
if(declaration instanceof ISeamJavaComponentDeclaration) {
javaDeclarations.add((ISeamJavaComponentDeclaration)declaration);
} else if(declaration instanceof ISeamXmlComponentDeclaration) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -16,7 +16,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
@@ -26,37 +25,17 @@
/**
* @author Viacheslav Kabanovich
*/
-public abstract class SeamComponentDeclaration implements ISeamComponentDeclaration {
+public abstract class SeamComponentDeclaration extends SeamObject implements ISeamComponentDeclaration {
public static final String PATH_OF_NAME = "name";
/**
- * Path of resource where this component is declared.
- */
- protected IPath source;
-
- protected IResource resource;
-
- /**
- * Object that allows to identify this declaration.
- */
- protected Object id;
-
- /**
* Seam component name.
*/
protected String name;
protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
- public Object getId() {
- return id;
- }
-
- public void setId(Object id) {
- this.id = id;
- }
-
public String getName() {
return name;
}
@@ -65,26 +44,11 @@
this.name = name;
}
- public void setSourcePath(IPath path) {
- source = path;
- }
-
- public IPath getSourcePath() {
- return source;
- }
-
public int getLength() {
// TODO Auto-generated method stub
return 0;
}
- public IResource getResource() {
- if(resource == null && source != null) {
- resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
- }
- return resource;
- }
-
public void setResource(IResource resource) {
this.resource = resource;
}
@@ -100,8 +64,10 @@
* @param d
* @return list of changes
*/
- public List<Change> merge(SeamComponentDeclaration d) {
- List<Change> changes = null;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamComponentDeclaration d = (SeamComponentDeclaration)s;
+
if(!source.equals(d.source)) {
source = d.source;
}
@@ -134,10 +100,6 @@
return valueInfo != null ? valueInfo.getLength() : 0;
}
- public IResource getResource() {
- return SeamComponentDeclaration.this.getResource();
- }
-
public int getStartPosition() {
return valueInfo != null ? valueInfo.getStartPosition() : 0;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -5,12 +5,11 @@
import org.jboss.tools.seam.core.ISeamComponentMethod;
import org.jboss.tools.seam.core.SeamComponentMethodType;
-public class SeamComponentMethod implements ISeamComponentMethod {
+public class SeamComponentMethod extends SeamObject implements ISeamComponentMethod {
boolean create = false;
boolean destroy = false;
IMember javaSource = null;
- IResource resource = null;
public boolean isCreate() {
return create;
@@ -47,7 +46,8 @@
}
public IResource getResource() {
- if(resource == null && javaSource != null) {
+ if(resource == null) {
+ if(javaSource == null) return super.getResource();
resource = javaSource.getResource();
}
return resource;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -58,15 +58,18 @@
}
public void addBijectedAttribute(IBijectedAttribute attribute) {
- bijectedAttributes.add(attribute);
+ bijectedAttributes.add(attribute);
+ adopt(attribute);
}
public void addMethod(ISeamComponentMethod method) {
componentMethods.add(method);
+ adopt(method);
}
public void addRole(IRole role) {
- roles.add(role);
+ roles.add(role);
+ adopt(role);
}
public Set<IBijectedAttribute> getBijectedAttributes() {
@@ -115,7 +118,7 @@
public Set<IRole> getRoles() {
return roles;
}
-
+
public boolean isEntity() {
return entity;
}
@@ -154,9 +157,9 @@
* @param d
* @return list of changes
*/
- public List<Change> merge(SeamComponentDeclaration d) {
- List<Change> changes = super.merge(d);
- SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)d;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)s;
if(!stringsEqual(className, jd.className)) {
changes = Change.addChange(changes, new Change(this, "class", className, jd.className));
className = jd.className;
@@ -183,8 +186,11 @@
//TODO do real merge and add changes to children
this.bijectedAttributes = jd.bijectedAttributes;
+ for (IBijectedAttribute a: bijectedAttributes) adopt(a);
this.componentMethods = jd.componentMethods;
- this.roles = jd.roles;
+ for (ISeamComponentMethod m: componentMethods) adopt(m);
+ this.roles = jd.roles;
+ for (IRole role: roles) adopt(role);
changes = Change.addChange(changes, children);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -27,7 +27,7 @@
}
public IResource getResource() {
- return javaSource == null ? null : javaSource.getTypeRoot().getResource();
+ return javaSource == null ? super.getResource() : javaSource.getTypeRoot().getResource();
}
public int getStartPosition() {
@@ -41,11 +41,11 @@
}
}
- public List<Change> merge(AbstractContextVariable f) {
- List<Change> changes = super.merge(f);
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
- if(f instanceof SeamJavaContextVariable) {
- SeamJavaContextVariable sf = (SeamJavaContextVariable)f;
+ if(s instanceof SeamJavaContextVariable) {
+ SeamJavaContextVariable sf = (SeamJavaContextVariable)s;
javaSource = sf.javaSource;
resource = sf.resource;
}
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.seam.core.ISeamObject;
+import org.jboss.tools.seam.core.event.Change;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamObject implements ISeamObject {
+ /**
+ * Object that allows to identify this object.
+ */
+ protected Object id;
+
+ /**
+ * Path of resource where this object is declared.
+ */
+ protected IPath source;
+
+ /**
+ * Resource where this object is declared.
+ */
+ protected IResource resource = null;
+
+ /**
+ * Parent seam object in the seam model.
+ */
+ protected ISeamObject parent;
+
+ public SeamObject() {}
+
+ public Object getId() {
+ return id;
+ }
+
+ /**
+ * Sets id for this object.
+ * For most objects it is object of Java or XML model
+ * from which this object is loaded.
+ */
+ public void setId(Object id) {
+ this.id = id;
+ }
+
+ /**
+ * Sets path of resource that declares this object.
+ */
+ public void setSourcePath(IPath path) {
+ source = path;
+ }
+
+ /**
+ * Returns path of resource that declares this object.
+ * @return
+ */
+ public IPath getSourcePath() {
+ if(source == null && parent != null) return parent.getSourcePath();
+ return source;
+ }
+
+ public IResource getResource() {
+ if(resource != null) return resource;
+ if(source != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ }
+ return resource;
+ }
+
+ /**
+ * Returns parent object of seam model.
+ * @return
+ */
+ public ISeamObject getParent() {
+ return parent;
+ }
+
+ public void setParent(ISeamObject parent) {
+ this.parent = parent;
+ }
+
+ protected void adopt(ISeamObject child) {
+ ((SeamObject)child).setParent(this);
+ }
+
+
+ /**
+ * Merges loaded object into current object.
+ * If changes were done returns a list of changes.
+ * @param f
+ * @return list of changes
+ */
+ public List<Change> merge(SeamObject s) {
+ source = s.source;
+ id = s.id;
+
+ return null;
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -18,10 +19,14 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamContextVariable;
@@ -30,6 +35,7 @@
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.Change;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
@@ -40,9 +46,13 @@
/**
* @author Viacheslav Kabanovich
*/
-public class SeamProject implements ISeamProject {
+public class SeamProject extends SeamObject implements ISeamProject {
IProject project;
ClassPath classPath = new ClassPath(this);
+
+ Set<IPath> sourcePaths = new HashSet<IPath>();
+ private boolean isStorageResolved = false;
+
Map<String, SeamComponent> allComponents = new HashMap<String, SeamComponent>();
protected Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
Set<ISeamContextVariable> allVariables = new HashSet<ISeamContextVariable>();
@@ -66,6 +76,7 @@
public void setProject(IProject project) {
this.project = project;
+ setSourcePath(project.getFullPath());
classPath.init();
load();
}
@@ -73,20 +84,62 @@
public ClassPath getClassPath() {
return classPath;
}
+
+ public void resolveStorage(boolean load) {
+ if(isStorageResolved) return;
+ if(load) {
+ load();
+ } else {
+ isStorageResolved = true;
+ }
+ }
/**
* Loads results of last build, which are considered
* actual until next build.
*/
- protected void load() {
+ public void load() {
+ if(isStorageResolved) return;
+ isStorageResolved = true;
+ long begin = System.currentTimeMillis();
+ if(getClassPath().update()) {
+ getClassPath().process();
+ }
+ File file = getStorageFile();
+ if(file == null || !file.isFile()) return;
+ String s = FileUtil.readFile(file);
+ String[] ps = s.split("\n");
+ for (int i = 0; i < ps.length; i++) {
+ IPath path = new Path(ps[i].trim());
+ if(sourcePaths.contains(path)) continue;
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if(f == null || !f.exists() || !f.isSynchronized(IResource.DEPTH_ZERO)) continue;
+ SeamResourceVisitor b = new SeamResourceVisitor(this);
+ b.visit(f);
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("loaded in " + (end - begin));
}
/**
* Stores results of last build, so that on exit/enter Eclipse
* load them without rebuilding project
*/
- protected void store() {
+ public void store() {
+ File file = getStorageFile();
+ file.getParentFile().mkdirs();
+ StringBuffer sb = new StringBuffer();
+ for (IPath path : sourcePaths) {
+ sb.append(path.toString()).append('\n');
+ }
+ FileUtil.writeFile(file, sb.toString());
}
+
+ private File getStorageFile() {
+ IPath path = SeamCorePlugin.getDefault().getStateLocation();
+ File file = new File(path.toFile(), "projects/" + project.getName());
+ return file;
+ }
public SeamValidationContext getValidationContext() {
if(validationContext==null) {
@@ -119,6 +172,7 @@
pathRemoved(source);
return;
}
+ if(!sourcePaths.contains(source)) sourcePaths.add(source);
Map<Object,ISeamComponentDeclaration> currentComponents = findComponentDeclarations(source);
@@ -204,6 +258,9 @@
fireChanges(changes);
continue;
}
+ if(factories[i].getParent() == null) {
+ adopt(factories[i]);
+ }
allFactories.add(factories[i]);
allVariables.add(factories[i]);
addedFactories = Change.addChange(addedFactories, new Change(this, null, null, loaded));
@@ -222,6 +279,8 @@
* @param source
*/
public void pathRemoved(IPath source) {
+ if(!sourcePaths.contains(source)) return;
+ sourcePaths.remove(source);
Iterator<SeamComponent> iterator = allComponents.values().iterator();
while(iterator.hasNext()) {
List<Change> changes = null;
@@ -436,6 +495,8 @@
SeamComponent newComponent(String name) {
SeamComponent c = new SeamComponent();
c.setName(name);
+ c.setId(name);
+ c.setParent(this);
return c;
}
@@ -478,4 +539,7 @@
}
return result;
}
+}
+
+class InnerBuilder {
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -17,6 +17,7 @@
public void addProperty(ISeamProperty property) {
properties.put(property.getName(), property);
+ adopt(property);
}
public List<ISeamProperty> getProperties(String propertyName) {
@@ -50,9 +51,9 @@
* @param d
* @return list of changes
*/
- public List<Change> merge(SeamComponentDeclaration d) {
- List<Change> changes = super.merge(d);
- SeamPropertiesDeclaration pd = (SeamPropertiesDeclaration)d;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamPropertiesDeclaration pd = (SeamPropertiesDeclaration)s;
Change children = new Change(this, null, null, null);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -14,12 +14,10 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IResource;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.core.event.Change;
-public class SeamProperty implements ISeamProperty {
- protected Object id;
+public class SeamProperty extends SeamObject implements ISeamProperty {
protected String name;
protected Object value;
protected int startPosition = -1;
@@ -41,14 +39,6 @@
this.value = value;
}
- public Object getId() {
- return id;
- }
-
- public void setId(Object id) {
- this.id = id;
- }
-
public String getName() {
return name;
}
@@ -77,18 +67,11 @@
this.value = value;
}
- /**
- * @see org.jboss.tools.seam.core.ISeamXmlElement#getResource()
- */
- public IResource getResource() {
- // TODO Auto-generated method stub
- return null;
- }
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+
+ SeamProperty d = (SeamProperty)s;
- public List<Change> merge(SeamProperty d) {
- List<Change> changes = null;
-
- id = d.id;
startPosition = d.startPosition;
length = d.length;
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
+import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamResourceVisitor implements IResourceVisitor {
+ static IFileScanner[] FILE_SCANNERS = {
+ new JavaScanner(),
+ new XMLScanner(),
+ };
+ SeamProject p;
+
+ public SeamResourceVisitor(SeamProject p) {
+ this.p = p;
+ }
+
+ public IResourceVisitor getVisitor() {
+ return this;
+ }
+
+ public boolean visit(IResource resource) {
+ if(resource instanceof IFile) {
+ IFile f = (IFile)resource;
+ for (int i = 0; i < FILE_SCANNERS.length; i++) {
+ IFileScanner scanner = FILE_SCANNERS[i];
+ if(scanner.isRelevant(f)) {
+ if(!scanner.isLikelyComponentSource(f)) return false;
+ LoadedDeclarations c = null;
+ try {
+ c = scanner.parse(f);
+ } catch (Exception e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ if(c != null) componentsLoaded(c, f);
+ }
+ }
+ }
+ //return true to continue visiting children.
+ return true;
+ }
+
+ void componentsLoaded(LoadedDeclarations c, IFile resource) {
+ if(c == null || c.getComponents().size() + c.getFactories().size() == 0) return;
+ p.registerComponents(c, resource.getFullPath());
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -83,9 +83,9 @@
* @param d
* @return list of changes
*/
- public List<Change> merge(SeamComponentDeclaration d) {
- List<Change> changes = super.merge(d);
- SeamXmlComponentDeclaration xd = (SeamXmlComponentDeclaration)d;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamXmlComponentDeclaration xd = (SeamXmlComponentDeclaration)s;
if(!stringsEqual(className, xd.className)) {
changes = Change.addChange(changes, new Change(this, CLASS, className, xd.className));
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -38,9 +38,9 @@
this.value = value;
}
- public List<Change> merge(AbstractContextVariable f) {
- List<Change> changes = super.merge(f);
- SeamXmlFactory xf = (SeamXmlFactory)f;
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamXmlFactory xf = (SeamXmlFactory)s;
if(!stringsEqual(value, xf.value)) {
changes = Change.addChange(changes, new Change(this, "value", value, xf.value));
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -133,7 +133,7 @@
MethodDeclaration m = n.getNode();
BijectedAttribute att = new BijectedAttribute();
- component.getBijectedAttributes().add(att);
+ component.addBijectedAttribute(att);
BijectedAttributeType[] types = (in == null) ? new BijectedAttributeType[]{BijectedAttributeType.OUT}
: (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
@@ -164,7 +164,7 @@
MethodDeclaration m = n.getNode();
SeamComponentMethod cm = new SeamComponentMethod();
- component.getMethods().add(cm);
+ component.addMethod(cm);
if(aCreate != null) cm.setCreate(true);
if(aDestroy != null) cm.setDestroy(true);
@@ -203,6 +203,8 @@
ValueInfo scope = ValueInfo.getValueInfo(role, "scope");
if(scope != null) r.setScope(scope);
+
+ component.addRole(r);
}
private Annotation findAnnotation(AnnotatedASTNode<?> n, String type) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-09 16:37:13 UTC (rev 2362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-10 10:37:43 UTC (rev 2363)
@@ -190,7 +190,7 @@
private void processBijection(Member m, Annotation in, Annotation out, SeamJavaComponentDeclaration component, LoadedDeclarations ds) {
if(in == null && out == null) return;
BijectedAttribute att = new BijectedAttribute();
- component.getBijectedAttributes().add(att);
+ component.addBijectedAttribute(att);
BijectedAttributeType[] types = (in == null) ? new BijectedAttributeType[]{BijectedAttributeType.OUT}
: (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
17 years, 5 months