Author: dgeraskov
Date: 2009-01-08 09:08:28 -0500 (Thu, 08 Jan 2009)
New Revision: 12929
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3454
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2009-01-08
13:42:00 UTC (rev 12928)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2009-01-08
14:08:28 UTC (rev 12929)
@@ -8,12 +8,12 @@
org.eclipse.jpt.core,
org.eclipse.wst.validation,
org.eclipse.jpt.utility;bundle-version="1.2.0",
- org.eclipse.core.resources;bundle-version="3.4.0",
org.hibernate.eclipse.console;bundle-version="3.2.0",
org.hibernate.eclipse;bundle-version="3.2.0",
org.eclipse.jdt.launching;bundle-version="3.4.0",
org.eclipse.debug.core;bundle-version="3.4.0",
- org.eclipse.emf.ecore;bundle-version="2.4.0"
+ org.eclipse.emf.ecore;bundle-version="2.4.0",
+ org.eclipse.jdt.core;bundle-version="3.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss, a division of Red Hat
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJpaAnnotationProvider extends GenericJpaAnnotationProvider {
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider#addAttributeAnnotationDefinitionsTo(java.util.Collection)
+ */
+ @Override
+ protected void
addAttributeAnnotationDefinitionsTo(Collection<AnnotationDefinition> definitions) {
+ super.addAttributeAnnotationDefinitionsTo(definitions);
+ definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2009-01-08
13:42:00 UTC (rev 12928)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal;
+import org.eclipse.jpt.core.JpaAnnotationProvider;
import org.eclipse.jpt.core.JpaFactory;
import org.eclipse.jpt.core.internal.platform.GenericJpaPlatform;
@@ -31,4 +32,10 @@
protected JpaFactory buildJpaFactory() {
return new HibernateFactory();
}
+
+ @Override
+ protected JpaAnnotationProvider buildAnnotationProvider() {
+ return new HibernateJpaAnnotationProvider();
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-01-08
13:42:00 UTC (rev 12928)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -15,6 +15,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -23,24 +24,32 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.Property;
import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlProperties;
import org.eclipse.jpt.core.resource.persistence.XmlProperty;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
/**
* @author Dmitry Geraskov
*
*/
public class HibernatePersistenceUnit extends GenericPersistenceUnit
- implements Messages {
+ implements Messages, Hibernate {
private HibernateProperties hibernateProperties;
@@ -55,6 +64,7 @@
protected void initialize(XmlPersistenceUnit xmlPersistenceUnit) {
super.initialize(xmlPersistenceUnit);
+ updateGenericGenerators();
this.hibernateProperties = new HibernateJpaProperties(this);
}
@@ -146,8 +156,33 @@
}
}
}
+
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit#update(org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit)
+ */
+ @Override
+ public void update(XmlPersistenceUnit persistenceUnit) {
+ super.update(persistenceUnit);
+ updateGenericGenerators();
+ }
+
+ protected void updateGenericGenerators(){
+ for (String annotClass :
CollectionTools.iterable(getJpaProject().annotatedClassNames())) {
+ ClassRef classRef = buildClassRef(annotClass);
+ JavaPersistentType type = classRef.getJavaPersistentType();
+ ListIterator<JavaPersistentAttribute> typeAttrs = type.attributes();
+ for (JavaPersistentAttribute persAttr : CollectionTools.iterable(typeAttrs)) {
+ JavaResourcePersistentAttribute jrpa = persAttr.getResourcePersistentAttribute();
+ GenericGeneratorAnnotation annotation = (GenericGeneratorAnnotation)
jrpa.getAnnotation(GENERIC_GENERATOR);
+ if (annotation != null){
+ JavaGenericGenerator generator =
annotation.buildJavaGenericGenerator(persAttr.getSpecifiedMapping());
+ addGenerator(generator);
+ }
+ }
+ }
+ }
-
/**
* Hack class needed to make JPA/Validation API pick up our classloader instead of its
own.
*
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.basic;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Hibernate {
+
+ // Hibernate package
+ String PACKAGE = "org.hibernate.annotations";
+ String PACKAGE_ = PACKAGE + ".";
+
+ // ********** API **********
+
+ // Hibernate annotations
+ String GENERIC_GENERATOR = PACKAGE_ + "GenericGenerator";
+ String GENERIC_GENERATOR__NAME = "name";
+ String GENERIC_GENERATOR__STRATEGY = "strategy";
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorAnnotation extends GeneratorAnnotation {
+
+ String ANNOTATION_NAME = Hibernate.GENERIC_GENERATOR;
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Returns null if the strategy element does not exist in java.
+ */
+ String getStrategy();
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Set to null to remove the strategy element.
+ */
+ void setStrategy(String strategy);
+ String STRATEGY_PROPERTY = "strategyProperty";
+
+ /**
+ * Return the {@link TextRange} for the strategy element. If the strategy element
+ * does not exist return the {@link TextRange} for the GenericGenerator annotation.
+ */
+ TextRange getStrategyTextRange(CompilationUnit astRoot);
+
+ JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent);
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorAnnotationImpl extends
AbstractResourceAnnotation<Member>
+ implements GenericGeneratorAnnotation {
+
+ private final AnnotationElementAdapter<String> nameAdapter;
+
+ private final AnnotationElementAdapter<String> strategyAdapter;
+
+ private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER =
buildNameAdapter();
+
+ private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER
= buildStrategyAdapter();
+
+ private String name;
+
+ private String strategy;
+
+ private Integer initialValue = 1;
+
+ private Integer allocationSize = 1;
+
+ /**
+ * @param parent
+ * @param member
+ */
+ public GenericGeneratorAnnotationImpl(JavaResourcePersistentMember parent, Member
member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
NAME_ADAPTER);
+ this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
STRATEGY_ADAPTER);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.name(astRoot);
+ this.strategy = this.strategy(astRoot);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public String getStrategy() {
+ return this.strategy;
+ }
+
+ public void setStrategy(String newStrategy) {
+ if (attributeValueHasNotChanged(this.strategy, newStrategy)) {
+ return;
+ }
+ String oldStrategy = this.strategy;
+ this.strategy = newStrategy;
+ this.strategyAdapter.setValue(newStrategy);
+ firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ if (attributeValueHasNotChanged(this.name, newName)) {
+ return;
+ }
+ String oldName = this.name;
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ firePropertyChanged(NAME_PROPERTY, oldName, newName);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(NAME_ADAPTER, astRoot);
+ }
+
+ public TextRange getStrategyTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(STRATEGY_ADAPTER, astRoot);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSize()
+ */
+ public Integer getAllocationSize() {
+ return allocationSize;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSizeTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValue()
+ */
+ public Integer getInitialValue() {
+ return initialValue;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValueTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public TextRange getInitialValueTextRange(CompilationUnit astRoot) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setAllocationSize(java.lang.Integer)
+ */
+ public void setAllocationSize(Integer allocationSize) {
+ this.allocationSize = allocationSize;
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setInitialValue(java.lang.Integer)
+ */
+ public void setInitialValue(Integer initialValue) {
+ this.initialValue = initialValue;
+
+ }
+
+ // ********** java annotations -> persistence model **********
+ public void updateFromJava(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ }
+
+ protected String strategy(CompilationUnit astRoot) {
+ //TODO: get Generator instead of String
+ //use buildJavaGenericGenerator method before thi will be done
+ return this.strategyAdapter.getValue(astRoot);
+ }
+
+ protected String name(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotation#buildJavaGenericGenerator(org.eclipse.jpt.core.context.java.JavaJpaContextNode)
+ */
+ public JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent) {
+ JavaGenericGenerator generator = new JavaGenericGeneratorImpl(parent);
+ generator.initializeFromResource(this);
+ return generator;
+ }
+
+ // ********** static methods **********
+ private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() {
+ return
ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER,
Hibernate.GENERIC_GENERATOR__NAME, false);
+ }
+
+ private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter()
{
+ return
ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER,
Hibernate.GENERIC_GENERATOR__STRATEGY, false);
+ }
+
+
+ public static class GenericGeneratorAnnotationDefinition implements
AnnotationDefinition
+ {
+ // singleton
+ private static final GenericGeneratorAnnotationDefinition INSTANCE = new
GenericGeneratorAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private GenericGeneratorAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member)
{
+ return new GenericGeneratorAnnotationImpl(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member
member) {
+ return null;
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.java.JavaGenerator;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaGenericGenerator extends JavaGenerator, GenericGenerator {
+
+ void initializeFromResource(GenericGeneratorAnnotation generator);
+
+ void update(GenericGeneratorAnnotation generator);
+
+}
+
+interface GenericGenerator extends Generator {
+
+ Integer DEFAULT_INITIAL_VALUE = Integer.valueOf(1);
+
+ String getStrategy();
+
+ void setSpecifiedStrategy(String value);
+ String GENERIC_STRATEGY_PROPERTY = "genericStrategyProperty";
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-01-08
14:08:28 UTC (rev 12929)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaGenerator;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class JavaGenericGeneratorImpl extends AbstractJavaGenerator
+ implements JavaGenericGenerator {
+
+ private String strategy;
+
+ /**
+ * @param parent
+ */
+ public JavaGenericGeneratorImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ @Override
+ protected GenericGeneratorAnnotation getGeneratorResource() {
+ return (GenericGeneratorAnnotation) super.getGeneratorResource();
+ }
+
+ public Integer getDefaultInitialValue() {
+ return GenericGenerator.DEFAULT_INITIAL_VALUE;
+ }
+
+ public void initializeFromResource(GenericGeneratorAnnotation generator) {
+ super.initializeFromResource(generator);
+ this.strategy = generator.getStrategy();
+ }
+
+ public void update(GenericGeneratorAnnotation generator) {
+ super.update(generator);
+ setSpecifiedStrategy_(generator.getStrategy());
+ }
+
+ public String getStrategy() {
+ return strategy;
+ }
+
+ public void setSpecifiedStrategy(String strategy) {
+ String oldStrategy = this.strategy;
+ this.strategy = strategy;
+ getGeneratorResource().setStrategy(strategy);
+ firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
+ }
+
+ protected void setSpecifiedStrategy_(String strategy) {
+ String oldStrategy = this.strategy;
+ this.strategy = strategy;
+ firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native