Author: dgeraskov
Date: 2009-07-23 09:40:36 -0400 (Thu, 23 Jul 2009)
New Revision: 16747
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
Removed:
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/HibernateNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.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/GenericGeneratorHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.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
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4649
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -15,11 +15,12 @@
import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider;
import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotationDefinition;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceGenericGeneratorsAnnotation.GenericGeneratorsAnnotationDefinition;
/**
* @author Dmitry Geraskov
@@ -51,6 +52,7 @@
@Override
protected void addTypeSupportingAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ definitions.add(GenericGeneratorsAnnotationDefinition.instance());
definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
Modified:
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 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -32,6 +32,9 @@
String GENERATOR_PARAMETER__NAME = "name"; //$NON-NLS-1$
String GENERATOR_PARAMETER__VALUE = "value"; //$NON-NLS-1$
+ String GENERIC_GENERATORS = PACKAGE_ + "GenericGenerators"; //$NON-NLS-1$
+ String GENERIC_GENERATORS__VALUE = "value"; //$NON-NLS-1$
+
String NAMED_QUERY = PACKAGE_ + "NamedQuery"; //$NON-NLS-1$
String NAMED_QUERY__NAME = "name"; //$NON-NLS-1$
String NAMED_QUERY__QUERY = "query"; //$NON-NLS-1$
Deleted:
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 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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 java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-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;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
-
-/**
- * @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"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- * Return an empty iterator if the element does not exist in Java.
- */
- ListIterator<ParameterAnnotation> parameters();
- String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- int parametersSize();
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- ParameterAnnotation parameterAt(int index);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- int indexOfParameter(ParameterAnnotation parameter);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- ParameterAnnotation addParameter(int index);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- void moveParameter(int targetIndex, int sourceIndex);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
- */
- void removeParameter(int index);
-
- /**
- * 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);
-
-}
Deleted:
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 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-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.AnnotationContainer;
-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.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.NestableParameterAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceParameterAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class GenericGeneratorAnnotationImpl extends SourceAnnotation<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();
-
- final ParametersAnnotationContainer parametersContainer = new
ParametersAnnotationContainer();
-
- private String name;
-
- private String strategy;
-
- final Vector<NestableParameterAnnotation> parameters = new
Vector<NestableParameterAnnotation>();
-
- private Integer initialValue = 1;
-
- private Integer allocationSize = 50;
-
- /**
- * @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);
- AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setStrategy(this.strategy(astRoot));
- this.setName(this.name(astRoot));
- AnnotationContainerTools.update(this.parametersContainer, 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);
- }
-
- 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 **********
- 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);
- }
-
- // ********** 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;
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.core.resource.java.AnnotationDefinition#buildAnnotation(org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember,
org.eclipse.jdt.core.IAnnotation)
- */
- public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
- IAnnotation arg1) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.core.resource.java.AnnotationDefinition#buildNullAnnotation(org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember)
- */
- public Annotation buildNullAnnotation(JavaResourcePersistentMember arg0) {
- // TODO Auto-generated method stub
- return null;
- }
- }
-
- //************************ parameters ***********************
-
- public ParameterAnnotation addParameter(int index) {
- return (NestableParameterAnnotation)
AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
- }
-
- NestableParameterAnnotation addParameterInternal() {
- NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
- this.parameters.add(parameter);
- return parameter;
- }
-
- NestableParameterAnnotation buildParameter(int index) {
- return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member,
this.daa, index);
- }
-
- ListIterator<NestableParameterAnnotation> nestableParameters() {
- return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
- }
-
- void parameterAdded(int index, NestableParameterAnnotation parameter) {
- this.fireItemAdded(PARAMETERS_LIST, index, parameter);
- }
-
- NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
- return CollectionTools.move(this.parameters, targetIndex,
sourceIndex).get(targetIndex);
- }
-
- void parameterMoved(int targetIndex, int sourceIndex) {
- this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
- }
-
- public int indexOfParameter(ParameterAnnotation parameter) {
- return this.parameters.indexOf(parameter);
- }
-
- public void moveParameter(int targetIndex, int sourceIndex) {
- AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.parametersContainer);
- }
-
- public ParameterAnnotation parameterAt(int index) {
- return this.parameters.get(index);
- }
-
- public ListIterator<ParameterAnnotation> parameters() {
- return new CloneListIterator<ParameterAnnotation>(this.parameters);
- }
-
- public int parametersSize() {
- return parameters.size();
- }
-
- public void removeParameter(int index) {
- AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
- }
-
- NestableParameterAnnotation removeParameterInternal(int index) {
- return this.parameters.remove(index);
- }
-
- void hintRemoved(int index, NestableParameterAnnotation parameter) {
- this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
- }
-
- /**
- * adapt the AnnotationContainer interface to the override's join columns
- */
- class ParametersAnnotationContainer
- implements AnnotationContainer<NestableParameterAnnotation>
- {
- public String getContainerAnnotationName() {
- return GenericGeneratorAnnotationImpl.this.getAnnotationName();
- }
-
- public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
- return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
- }
-
- public String getElementName() {
- return Hibernate.GENERIC_GENERATOR__PARAMETERS;
- }
-
- public String getNestableAnnotationName() {
- return ParameterAnnotation.ANNOTATION_NAME;
- }
-
- public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
- return GenericGeneratorAnnotationImpl.this.nestableParameters();
- }
-
- public int nestedAnnotationsSize() {
- return GenericGeneratorAnnotationImpl.this.parametersSize();
- }
-
- public NestableParameterAnnotation addNestedAnnotationInternal() {
- return GenericGeneratorAnnotationImpl.this.addParameterInternal();
- }
-
- public void nestedAnnotationAdded(int index, NestableParameterAnnotation
nestedAnnotation) {
- GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
- }
-
- public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
- return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex,
sourceIndex);
- }
-
- public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
- GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
- }
-
- public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
- return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
- }
-
- public void nestedAnnotationRemoved(int index, NestableParameterAnnotation
nestedAnnotation) {
- GenericGeneratorAnnotationImpl.this.hintRemoved(index, nestedAnnotation);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jpt.core.context.GeneratorHolder;
/**
@@ -17,13 +19,38 @@
*
*/
public interface GenericGeneratorHolder extends GeneratorHolder {
+
+ String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
- String GENERIC_GENERATOR_PROPERTY = "genericGenerator"; //$NON-NLS-1$
+ /**
+ * Return a list iterator of the generic generators.
+ * This will not be null.
+ */
+ <T extends GenericGenerator> ListIterator<T> genericGenerators();
- JavaGenericGenerator getGenericGenerator();
+ /**
+ * Return the number of generic generators.
+ */
+ int genericGeneratorsSize();
- JavaGenericGenerator addGenericGenerator();
+ /**
+ * Add a generic generator to the entity return the object representing it.
+ */
+ GenericGenerator addGenericGenerator(int index);
- void removeGenericGenerator();
+ /**
+ * Remove the generic generator at the index from the entity.
+ */
+ void removeGenericGenerator(int index);
+
+ /**
+ * Remove the generic generator from the entity.
+ */
+ void removeGenericGenerator(GenericGenerator generator);
+
+ /**
+ * Move the generic generator from the source index to the target index.
+ */
+ void moveGenericGenerator(int targetIndex, int sourceIndex);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -31,7 +31,10 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorsAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
@@ -42,7 +45,7 @@
public class HibernateJavaEntity extends AbstractJavaEntity
implements GenericGeneratorHolder, HibernateQueryContainer {
- protected JavaGenericGenerator genericGenerator;
+ protected final List<JavaGenericGenerator> genericGenerators;
protected final List<HibernateNamedQuery> hibernateNamedQueries;
@@ -50,6 +53,7 @@
public HibernateJavaEntity(JavaPersistentType parent) {
super(parent);
+ this.genericGenerators = new ArrayList<JavaGenericGenerator>();
this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
}
@@ -57,7 +61,7 @@
@Override
public void initialize(JavaResourcePersistentType resourcePersistentType) {
super.initialize(resourcePersistentType);
- this.initializeGenericGenerator();
+ this.initializeGenericGenerators();
this.initializeHibernateNamedQueries();
this.initializeHibernateNamedNativeQueries();
}
@@ -65,9 +69,13 @@
@Override
public void update(JavaResourcePersistentType resourcePersistentType) {
super.update(resourcePersistentType);
- this.updateGenericGenerator();
+ this.updateGenericGenerators();
this.updateHibernateNamedQueries();
this.updateHibernateNamedNativeQueries();
+ }
+
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
}
@SuppressWarnings("unchecked")
@@ -79,95 +87,106 @@
this.hibernateNamedNativeQueries());
}
- // ********************* GenericGenerator **************
@SuppressWarnings("unchecked")
@Override
public Iterator<String> correspondingAnnotationNames() {
return new CompositeIterator<String>(
- new ArrayIterator<String>(Hibernate.GENERIC_GENERATOR,
- Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES,
- Hibernate.NAMED_NATIVE_QUERY,
- Hibernate.NAMED_NATIVE_QUERIES),
+ new ArrayIterator<String>(
+ Hibernate.GENERIC_GENERATOR,
+ Hibernate.GENERIC_GENERATORS,
+ Hibernate.NAMED_QUERY,
+ Hibernate.NAMED_QUERIES,
+ Hibernate.NAMED_NATIVE_QUERY,
+ Hibernate.NAMED_NATIVE_QUERIES),
super.correspondingAnnotationNames());
}
- public void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,
newGenericGenerator);
+ // ********************* GenericGenerators **************
+
+ public GenericGenerator addGenericGenerator(int index) {
+ JavaGenericGenerator newGenericGenerator =
getJpaFactory().buildJavaGenericGenerator(this);
+ this.genericGenerators.add(newGenericGenerator);
+ GenericGeneratorAnnotation genericGeneratorAnnotation =
(GenericGeneratorAnnotation)this.javaResourcePersistentType
+ .addSupportingAnnotation(index, GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ newGenericGenerator.initialize(genericGeneratorAnnotation);
+ fireItemAdded(GENERIC_GENERATORS_LIST, index, newGenericGenerator);
+ return newGenericGenerator;
}
- protected HibernateJpaFactory getJpaFactory() {
- return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
+ protected void addGenericGenerator(JavaGenericGenerator genericGenerator) {
+ this.addGenericGenerator(genericGeneratorsSize(), genericGenerator);
}
- protected void initializeGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource != null) {
- this.genericGenerator = buildGenericGenerator(genericGeneratorResource);
- }
+ protected void addGenericGenerator(int index, JavaGenericGenerator genericGenerator) {
+ addItemToList(index, genericGenerator, this.genericGenerators,
GENERIC_GENERATORS_LIST);
}
- protected GenericGeneratorAnnotation getResourceGenericGenerator() {
- return (GenericGeneratorAnnotation)
this.javaResourcePersistentType.getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ @SuppressWarnings("unchecked")
+ public ListIterator<JavaGenericGenerator> genericGenerators() {
+ return new CloneListIterator<JavaGenericGenerator>(genericGenerators);
}
-
- protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
- JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
- generator.initialize(genericGeneratorResource);
- return generator;
+
+ public int genericGeneratorsSize() {
+ return this.genericGenerators.size();
}
- public JavaGenericGenerator addGenericGenerator() {
- if (getGenericGenerator() != null) {
- throw new IllegalStateException("genericGenerator already exists");
//$NON-NLS-1$
- }
- this.genericGenerator = getJpaFactory().buildJavaGenericGenerator(this);
- GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)javaResourcePersistentType
- .addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, null, this.genericGenerator);
- return this.genericGenerator;
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.genericGenerators, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
GenericGeneratorAnnotation.ANNOTATION_NAME);
+ fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
}
- public JavaGenericGenerator getGenericGenerator() {
- return genericGenerator;
+ public void removeGenericGenerator(int index) {
+ JavaGenericGenerator removedGenericGenerator = this.genericGenerators.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index,
GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(GENERIC_GENERATORS_LIST, index, removedGenericGenerator);
}
- public void removeGenericGenerator() {
- if (getGenericGenerator() == null) {
- throw new IllegalStateException("genericGenerator does not exist, cannot be
removed"); //$NON-NLS-1$
+ public void removeGenericGenerator(GenericGenerator generator) {
+ removeGenericGenerator(this.genericGenerators.indexOf(generator));
+ }
+
+ protected void removeGenericGenerator_(JavaGenericGenerator generator) {
+ removeItemFromList(generator, this.genericGenerators, GENERIC_GENERATORS_LIST);
+ }
+
+ protected void initializeGenericGenerators() {
+ for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.genericGenerators.add(buildGenericGenerator((GenericGeneratorAnnotation)
stream.next()));
}
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = null;
- this.javaResourcePersistentType.removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,null);
}
+ protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
+ JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
+ generator.initialize(genericGeneratorResource);
+ return generator;
+ }
+
@Override
protected void addGeneratorsTo(ArrayList<JavaGenerator> generators) {
super.addGeneratorsTo(generators);
- if (this.genericGenerator != null) {
- generators.add(this.genericGenerator);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ generators.add(genericGenerator);
}
}
- protected void updateGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource == null) {
- if (getGenericGenerator() != null) {
- setGenericGenerator(null);
+ protected void updateGenericGenerators() {
+ ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
+ ListIterator<NestableAnnotation> resourceGenericGenerators =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
+
+ while (genericGenerators.hasNext()) {
+ JavaGenericGenerator genericGenerator = genericGenerators.next();
+ if (resourceGenericGenerators.hasNext()) {
+ genericGenerator.update((GenericGeneratorAnnotation)
resourceGenericGenerators.next());
}
- }
- else {
- if (getGenericGenerator() == null) {
- setGenericGenerator(buildGenericGenerator(genericGeneratorResource));
- }
else {
- getGenericGenerator().update(genericGeneratorResource);
+ removeGenericGenerator_(genericGenerator);
}
}
+
+ while (resourceGenericGenerators.hasNext()) {
+ addGenericGenerator(buildGenericGenerator((GenericGeneratorAnnotation)
resourceGenericGenerators.next()));
+ }
}
// ********************* NamedQuery **************
public ListIterator<HibernateNamedQuery> hibernateNamedQueries() {
@@ -337,9 +356,9 @@
}
protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
- if (genericGenerator != null){
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
genericGenerator.validate(messages, reporter, astRoot);
- }
+ }
}
@Override
@@ -349,8 +368,8 @@
if (result != null) {
return result;
}
- if (this.getGenericGenerator() != null) {
- result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ result = genericGenerator.javaCompletionProposals(pos, filter, astRoot);
if (result != null) {
return result;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -12,6 +12,7 @@
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
@@ -20,10 +21,13 @@
import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
/**
* @author Dmitry Geraskov
@@ -71,7 +75,7 @@
: new SingleElementIterator(getGenericGenerator()));
}
- public JavaGenericGenerator addGenericGenerator() {
+ public JavaGenericGenerator addGenericGenerator(int index) {
if (getGenericGenerator() != null) {
throw new IllegalStateException("genericGenerator already exists");
//$NON-NLS-1$
}
@@ -79,28 +83,28 @@
GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)getResourcePersistentAttribute()
.addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, null, this.genericGenerator);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
return this.genericGenerator;
}
- public JavaGenericGenerator getGenericGenerator() {
+ private JavaGenericGenerator getGenericGenerator() {
return genericGenerator;
}
- public void removeGenericGenerator() {
+ private void removeGenericGenerator() {
if (getGenericGenerator() == null) {
throw new IllegalStateException("genericGenerator does not exist, cannot be
removed"); //$NON-NLS-1$
}
JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
this.genericGenerator = null;
this.getResourcePersistentAttribute().removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,null);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
}
- public void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
+ private void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,
newGenericGenerator);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,
newGenericGenerator);
}
@Override
@@ -132,7 +136,7 @@
validateGenericGenerator(messages, reporter, astRoot);
}
- protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
+ private void validateGenericGenerator(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
if (genericGenerator != null){
genericGenerator.validate(messages, reporter, astRoot);
}
@@ -154,4 +158,30 @@
return null;
}
+ public ListIterator<GenericGenerator> genericGenerators() {
+ return genericGenerator == null ?
EmptyListIterator.<GenericGenerator>instance()
+ : new SingleElementListIterator<GenericGenerator>(genericGenerator);
+ }
+
+ public int genericGeneratorsSize() {
+ return genericGenerator == null ? 0 : 1;
+ }
+
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeGenericGenerator(int index) {
+ if (genericGeneratorsSize() < index + 1){
+ throw new IndexOutOfBoundsException();
+ }
+ removeGenericGenerator();
+ }
+
+ public void removeGenericGenerator(GenericGenerator generator) {
+ if (this.genericGenerator == generator){
+ removeGenericGenerator();
+ }
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaNamedNativeQuery;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.resource.java.NestableNamedNativeQueryAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-/**
- * @author Dmitry Geraskov
- *
- * Corresponds to the Hibernate annotation
- * org.hibernate.annotations.NamedNativeQuery
- */
-public interface HibernateNamedNativeQueryAnnotation
- extends NestableNamedNativeQueryAnnotation, HibernateQueryAnnotation {
- //replace with Hibernate annotation
- String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERY;
-
- //************************ callable *********************************
- Boolean isCallable();
- void setCallable(Boolean value);
- String CALLABLE_PROPERTY = "callable"; //$NON-NLS-1$
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -12,6 +12,7 @@
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedNativeQuery;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.utility.TextRange;
-
-/**
- * @author Dmitry Geraskov
- *
- * Interface contains Hibernate specific attributes.
- */
-public interface HibernateQueryAnnotation {
-
- //************************ flushMode *********************************
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- FlushModeType getFlushMode();
- String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setFlushMode(FlushModeType flushMode);
-
- /**
- * Return the {@link TextRange} for the 'flushMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getFlushModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheMode *********************************
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- CacheModeType getCacheMode();
- String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setCacheMode(CacheModeType cacheMode);
-
- /**
- * Return the {@link TextRange} for the 'cacheMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getCacheModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheable *********************************
- Boolean isCacheable();
- void setCacheable(Boolean value);
- String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
-
- //************************ cacheRegion *********************************
- String getCacheRegion();
- void setCacheRegion(String value);
- String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
-
- //************************ fetchSize *********************************
- Integer getFetchSize();
- void setFetchSize(Integer value);
- String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
-
- //************************ timeout *********************************
- Integer getTimeout();
- void setTimeout(Integer value);
- String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
-
- //************************ comment *********************************
- String getComment();
- void setComment(String value);
- String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
-
- //************************ readOnly *********************************
- Boolean isReadOnly();
- void setReadOnly(Boolean value);
- String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,613 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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 java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import
org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-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.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateSourceNamedNativeQueryAnnotation extends
SourceAnnotation<Member> implements
- HibernateNamedNativeQueryAnnotation {
-
- public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
- private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
- private final AnnotationElementAdapter<String> nameAdapter;
- private String name;
-
- private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
- private final AnnotationElementAdapter<String> queryAdapter;
- private String query;
-
- private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> flushModeAdapter;
- private FlushModeType flushMode;
-
- private final DeclarationAnnotationElementAdapter<String>
cacheModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheModeAdapter;
- private CacheModeType cacheMode;
-
- private final DeclarationAnnotationElementAdapter<Boolean>
cacheableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> cacheableAdapter;
- private Boolean cacheable;
-
- private final DeclarationAnnotationElementAdapter<String>
cacheRegionDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheRegionAdapter;
- private String cacheRegion;
-
- private final DeclarationAnnotationElementAdapter<Integer>
fetchSizeDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
- private Integer fetchSize;
-
- private final DeclarationAnnotationElementAdapter<Integer>
timeoutDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> timeoutAdapter;
- private Integer timeout;
-
- private final DeclarationAnnotationElementAdapter<String>
commentDeclarationAdapter;
- private final AnnotationElementAdapter<String> commentAdapter;
- private String comment;
-
- private final DeclarationAnnotationElementAdapter<Boolean>
readOnlyDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
- private Boolean readOnly;
-
- private final DeclarationAnnotationElementAdapter<Boolean>
callableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> callableAdapter;
- private Boolean callable;
-
- private final DeclarationAnnotationElementAdapter<String>
resultClassDeclarationAdapter;
- private final AnnotationElementAdapter<String> resultClassAdapter;
- private String resultClass;
-
- private String fullyQualifiedResultClassName;
-
- private final DeclarationAnnotationElementAdapter<String>
resultSetMappingDeclarationAdapter;
- private final AnnotationElementAdapter<String> resultSetMappingAdapter;
- private String resultSetMapping;
-
- HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
- super(parent, member, daa, annotationAdapter);
- this.nameDeclarationAdapter = this.buildNameAdapter(daa);
- this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
- this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
- this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
- this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
- this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
flushModeDeclarationAdapter);
- this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
- this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
cacheModeDeclarationAdapter);
- this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
- this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
cacheableDeclarationAdapter);
- this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
- this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
- this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
- this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
fetchSizeDeclarationAdapter);
- this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
- this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
timeoutDeclarationAdapter);
- this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
- this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
commentDeclarationAdapter);
- this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
readOnlyDeclarationAdapter);
- this.callableDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.callableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
callableDeclarationAdapter);
- this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa);
- this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter);
- this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
- this.resultSetMappingAdapter =
this.buildAdapter(this.resultSetMappingDeclarationAdapter);
- }
-
- public void initialize(CompilationUnit astRoot) {
- this.name = this.buildName(astRoot);
- this.query = this.buildQuery(astRoot);
- this.flushMode = this.buildFlushMode(astRoot);
- this.cacheMode = this.buildCacheMode(astRoot);
- this.cacheable = this.buildCacheable(astRoot);
- this.cacheRegion = this.buildCacheRegion(astRoot);
- this.fetchSize = this.buildFetchSize(astRoot);
- this.timeout = this.buildTimeout(astRoot);
- this.comment = this.buildComment(astRoot);
- this.readOnly = this.buildReadOnly(astRoot);
- this.callable = this.buildCallable(astRoot);
- this.resultClass = this.buildResultClass(astRoot);
- this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot);
- this.resultSetMapping = this.buildResultSetMapping(astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setName(this.buildName(astRoot));
- this.setQuery(this.buildQuery(astRoot));
- this.setFlushMode(this.buildFlushMode(astRoot));
- this.setCacheMode(this.buildCacheMode(astRoot));
- this.setCacheable(this.buildCacheable(astRoot));
- this.setCacheRegion(this.buildCacheRegion(astRoot));
- this.setFetchSize(this.buildFetchSize(astRoot));
- this.setTimeout(this.buildTimeout(astRoot));
- this.setComment(this.buildComment(astRoot));
- this.setReadOnly(this.buildReadOnly(astRoot));
- this.setCallable(this.buildCallable(astRoot));
- this.setResultClass(this.buildResultClass(astRoot));
- this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
- this.setResultSetMapping(this.buildResultSetMapping(astRoot));
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- /**
- * convenience method
- */
- AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
- return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
- }
-
- // ********** BaseNamedNativeQueryAnnotation implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (this.attributeValueHasNotChanged(this.name, name)) {
- return;
- }
- String old = this.name;
- this.name = name;
- this.nameAdapter.setValue(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- private String buildName(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
- }
-
- // ***** query
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- if (this.attributeValueHasNotChanged(this.query, query)) {
- return;
- }
- String old = this.query;
- this.query = query;
- this.queryAdapter.setValue(query);
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
- private String buildQuery(CompilationUnit astRoot) {
- return this.queryAdapter.getValue(astRoot);
- }
-
- public TextRange getQueryTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
- }
-
- String getQueryElementName() {
- return Hibernate.NAMED_NATIVE_QUERY__QUERY;
- }
-
- // ***** hints
- public ListIterator<QueryHintAnnotation> hints() {
- return EmptyListIterator.instance();
- }
-
- ListIterator<NestableQueryHintAnnotation> nestableHints() {
- return EmptyListIterator.instance();
- }
-
- public int hintsSize() {
- return 0;
- }
-
- public NestableQueryHintAnnotation hintAt(int index) {
- throw new UnsupportedOperationException();
- }
-
- public int indexOfHint(QueryHintAnnotation queryHint) {
- return -1;
- }
-
- public NestableQueryHintAnnotation addHint(int index) {
- return null;
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.hintsContainer);
- }
-
- public void removeHint(int index) {
- //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
- }
-
- // ******************** HibernateNamedNativeQueryAnnotation implementation
*************
- // ***** flushMode
-
- public FlushModeType getFlushMode() {
- return flushMode;
- }
-
- public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
- return;
- }
- FlushModeType old = this.flushMode;
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
- this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
- }
-
- private FlushModeType buildFlushMode(CompilationUnit astRoot) {
- return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
- }
-
- public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
- }
-
- // ***** caheMode
-
- public CacheModeType getCacheMode() {
- return cacheMode;
- }
-
- public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
- return;
- }
- CacheModeType old = this.cacheMode;
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
- this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
- }
-
- private CacheModeType buildCacheMode(CompilationUnit astRoot) {
- return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
- }
-
- public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
- }
-
- //************************ cacheable *********************************
- public Boolean isCacheable(){
- return this.cacheable;
- }
-
- public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
- return;
- }
- Boolean old = this.cacheable;
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
- this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
- }
-
- private Boolean buildCacheable(CompilationUnit astRoot) {
- return this.cacheableAdapter.getValue(astRoot);
- }
-
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return this.cacheRegion;
- }
-
- public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
- return;
- }
- String old = this.cacheRegion;
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
- this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
- }
-
- private String buildCacheRegion(CompilationUnit astRoot) {
- return this.cacheRegionAdapter.getValue(astRoot);
- }
- //************************ fetchSize *********************************
- public Integer getFetchSize(){
- return this.fetchSize;
- }
-
- public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
- return;
- }
- Integer old = this.fetchSize;
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
- this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
- }
-
- private Integer buildFetchSize(CompilationUnit astRoot) {
- return this.fetchSizeAdapter.getValue(astRoot);
- }
- //************************ timeout *********************************
- public Integer getTimeout(){
- return this.timeout;
- }
- public void setTimeout(Integer timeout){
- if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
- return;
- }
- Integer old = this.timeout;
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
- this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
- }
-
- private Integer buildTimeout(CompilationUnit astRoot) {
- return this.timeoutAdapter.getValue(astRoot);
- }
- //************************ comment *********************************
- public String getComment(){
- return this.comment;
- }
-
- public void setComment(String comment){
- if (this.attributeValueHasNotChanged(this.comment, comment)) {
- return;
- }
- String old = this.comment;
- this.comment = comment;
- this.commentAdapter.setValue(comment);
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
- private String buildComment(CompilationUnit astRoot) {
- return this.commentAdapter.getValue(astRoot);
- }
- //************************ readOnly *********************************
- public Boolean isReadOnly(){
- return this.readOnly;
- }
-
- public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
- return;
- }
- Boolean old = this.readOnly;
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
- }
-
- private Boolean buildReadOnly(CompilationUnit astRoot) {
- return this.readOnlyAdapter.getValue(astRoot);
- }
- //************************ callable *********************************
- public Boolean isCallable(){
- return this.callable;
- }
-
- public void setCallable(Boolean callable){
- if (this.attributeValueHasNotChanged(this.callable, callable)) {
- return;
- }
- Boolean old = this.callable;
- this.callable = callable;
- this.callableAdapter.setValue(callable);
- this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
- }
-
- private Boolean buildCallable(CompilationUnit astRoot) {
- return this.callableAdapter.getValue(astRoot);
- }
- // ***** result class
- public String getResultClass() {
- return this.resultClass;
- }
-
- public void setResultClass(String resultClass) {
- if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
- return;
- }
- String old = this.resultClass;
- this.resultClass = resultClass;
- this.resultClassAdapter.setValue(resultClass);
- this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
- }
-
- private String buildResultClass(CompilationUnit astRoot) {
- return this.resultClassAdapter.getValue(astRoot);
- }
-
- public TextRange getResultClassTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot);
- }
-
- // ***** fully-qualified result class name
- public String getFullyQualifiedResultClassName() {
- return this.fullyQualifiedResultClassName;
- }
-
- private void setFullyQualifiedResultClassName(String name) {
- String old = this.fullyQualifiedResultClassName;
- this.fullyQualifiedResultClassName = name;
- this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
- }
-
- private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
- return (this.resultClass == null) ? null :
JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
- }
-
- // ***** result set mapping
- public String getResultSetMapping() {
- return this.resultSetMapping;
- }
-
- public void setResultSetMapping(String resultSetMapping) {
- if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
- return;
- }
- String old = this.resultSetMapping;
- this.resultSetMapping = resultSetMapping;
- this.resultSetMappingAdapter.setValue(resultSetMapping);
- this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
- }
-
- private String buildResultSetMapping(CompilationUnit astRoot) {
- return this.resultSetMappingAdapter.getValue(astRoot);
- }
-
- public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot);
- }
- // ********** NestableAnnotation implementation **********
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void initializeFrom(NestableAnnotation oldAnnotation) {
- HibernateSourceNamedNativeQueryAnnotation oldQuery =
(HibernateSourceNamedNativeQueryAnnotation) oldAnnotation;
- this.setName(oldQuery.getName());
- this.setQuery(oldQuery.getQuery());
- this.setFlushMode(oldQuery.getFlushMode());
- this.setCacheMode(oldQuery.getCacheMode());
- this.setCacheable(oldQuery.isCacheable());
- this.setComment(oldQuery.getComment());
- this.setFetchSize(oldQuery.getFetchSize());
- this.setTimeout(oldQuery.getTimeout());
- this.setCacheRegion(oldQuery.getCacheRegion());
- this.setReadOnly(oldQuery.isReadOnly());
- this.setCallable(oldQuery.isCallable());
- this.setResultClass(oldQuery.getResultClass());
- this.setResultSetMapping(oldQuery.getResultSetMapping());
- }
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void moveAnnotation(int newIndex) {
- this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
- }
-
- private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
- return (IndexedAnnotationAdapter) this.annotationAdapter;
- }
-
- public static HibernateNamedNativeQueryAnnotation
createNamedNativeQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__NAME);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__QUERY);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__FLUSH_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHE_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean>
buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHEABLE);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHE_REGION);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer>
buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__FETCH_SIZE);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer>
buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__TIMEOUT);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__COMMENT);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean>
buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__READ_ONLY);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean>
buildCallableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CALLABLE);
- }
-
-
- private DeclarationAnnotationElementAdapter<String>
buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__RESULT_CLASS,
SimpleTypeStringExpressionConverter.instance());
- }
-
- private DeclarationAnnotationElementAdapter<String>
buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ********** static methods **********
-
- public static HibernateSourceNamedNativeQueryAnnotation
createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
- }
-
- public static HibernateSourceNamedNativeQueryAnnotation
createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
- IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
- IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member,
idaa);
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa,
annotationAdapter);
- }
-
- private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateNamedNativeQueriesAdapter) {
- return new
NestedIndexedDeclarationAnnotationAdapter(hibernateNamedNativeQueriesAdapter, index,
Hibernate.NAMED_NATIVE_QUERY);
- }
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -1,489 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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 java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import
org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-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.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-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.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
- implements HibernateNamedQueryAnnotation {
-
- public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
- private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
- private final AnnotationElementAdapter<String> nameAdapter;
- private String name;
-
- private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
- private final AnnotationElementAdapter<String> queryAdapter;
- private String query;
-
- private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> flushModeAdapter;
- private FlushModeType flushMode;
-
- private final DeclarationAnnotationElementAdapter<String>
cacheModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheModeAdapter;
- private CacheModeType cacheMode;
-
- private final DeclarationAnnotationElementAdapter<Boolean>
cacheableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> cacheableAdapter;
- private Boolean cacheable;
-
- private final DeclarationAnnotationElementAdapter<String>
cacheRegionDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheRegionAdapter;
- private String cacheRegion;
-
- private final DeclarationAnnotationElementAdapter<Integer>
fetchSizeDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
- private Integer fetchSize;
-
- private final DeclarationAnnotationElementAdapter<Integer>
timeoutDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> timeoutAdapter;
- private Integer timeout;
-
- private final DeclarationAnnotationElementAdapter<String>
commentDeclarationAdapter;
- private final AnnotationElementAdapter<String> commentAdapter;
- private String comment;
-
- private final DeclarationAnnotationElementAdapter<Boolean>
readOnlyDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
- private Boolean readOnly;
-
- HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
- super(parent, member, daa, annotationAdapter);
- this.nameDeclarationAdapter = this.buildNameAdapter(daa);
- this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
- this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
- this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
- this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
- this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
flushModeDeclarationAdapter);
- this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
- this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
cacheModeDeclarationAdapter);
- this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
- this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
cacheableDeclarationAdapter);
- this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
- this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
- this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
- this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
fetchSizeDeclarationAdapter);
- this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
- this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
timeoutDeclarationAdapter);
- this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
- this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
commentDeclarationAdapter);
- this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
readOnlyDeclarationAdapter);
- }
-
- public void initialize(CompilationUnit astRoot) {
- this.name = this.buildName(astRoot);
- this.query = this.buildQuery(astRoot);
- this.flushMode = this.buildFlushMode(astRoot);
- this.cacheMode = this.buildCacheMode(astRoot);
- this.cacheable = this.buildCacheable(astRoot);
- this.cacheRegion = this.buildCacheRegion(astRoot);
- this.fetchSize = this.buildFetchSize(astRoot);
- this.timeout = this.buildTimeout(astRoot);
- this.comment = this.buildComment(astRoot);
- this.readOnly = this.buildReadOnly(astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setName(this.buildName(astRoot));
- this.setQuery(this.buildQuery(astRoot));
- this.setFlushMode(this.buildFlushMode(astRoot));
- this.setCacheMode(this.buildCacheMode(astRoot));
- this.setCacheable(this.buildCacheable(astRoot));
- this.setCacheRegion(this.buildCacheRegion(astRoot));
- this.setFetchSize(this.buildFetchSize(astRoot));
- this.setTimeout(this.buildTimeout(astRoot));
- this.setComment(this.buildComment(astRoot));
- this.setReadOnly(this.buildReadOnly(astRoot));
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- /**
- * convenience method
- */
- AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
- return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
- }
-
- // ********** BaseNamedQueryAnnotation implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (this.attributeValueHasNotChanged(this.name, name)) {
- return;
- }
- String old = this.name;
- this.name = name;
- this.nameAdapter.setValue(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- private String buildName(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
- }
-
- // ***** query
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- if (this.attributeValueHasNotChanged(this.query, query)) {
- return;
- }
- String old = this.query;
- this.query = query;
- this.queryAdapter.setValue(query);
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
- private String buildQuery(CompilationUnit astRoot) {
- return this.queryAdapter.getValue(astRoot);
- }
-
- public TextRange getQueryTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
- }
-
- String getQueryElementName() {
- return Hibernate.NAMED_QUERY__QUERY;
- }
-
- // ***** hints
- public ListIterator<QueryHintAnnotation> hints() {
- return EmptyListIterator.instance();
- }
-
- ListIterator<NestableQueryHintAnnotation> nestableHints() {
- return EmptyListIterator.instance();
- }
-
- public int hintsSize() {
- return 0;
- }
-
- public NestableQueryHintAnnotation hintAt(int index) {
- throw new UnsupportedOperationException();
- }
-
- public int indexOfHint(QueryHintAnnotation queryHint) {
- return -1;
- }
-
- public NestableQueryHintAnnotation addHint(int index) {
- return null;
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.hintsContainer);
- }
-
- public void removeHint(int index) {
- //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
- }
-
- // ******************** HibernateNamedQueryAnnotation implementation *************
- // ***** flushMode
-
- public FlushModeType getFlushMode() {
- return flushMode;
- }
-
- public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
- return;
- }
- FlushModeType old = this.flushMode;
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
- this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
- }
-
- private FlushModeType buildFlushMode(CompilationUnit astRoot) {
- return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
- }
-
- public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
- }
-
- // ***** caheMode
-
- public CacheModeType getCacheMode() {
- return cacheMode;
- }
-
- public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
- return;
- }
- CacheModeType old = this.cacheMode;
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
- this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
- }
-
- private CacheModeType buildCacheMode(CompilationUnit astRoot) {
- return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
- }
-
- public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
- }
-
- //************************ cacheable *********************************
- public Boolean isCacheable(){
- return this.cacheable;
- }
-
- public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
- return;
- }
- Boolean old = this.cacheable;
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
- this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
- }
-
- private Boolean buildCacheable(CompilationUnit astRoot) {
- return this.cacheableAdapter.getValue(astRoot);
- }
-
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return this.cacheRegion;
- }
-
- public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
- return;
- }
- String old = this.cacheRegion;
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
- this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
- }
-
- private String buildCacheRegion(CompilationUnit astRoot) {
- return this.cacheRegionAdapter.getValue(astRoot);
- }
- //************************ fetchSize *********************************
- public Integer getFetchSize(){
- return this.fetchSize;
- }
-
- public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
- return;
- }
- Integer old = this.fetchSize;
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
- this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
- }
-
- private Integer buildFetchSize(CompilationUnit astRoot) {
- return this.fetchSizeAdapter.getValue(astRoot);
- }
- //************************ timeout *********************************
- public Integer getTimeout(){
- return this.timeout;
- }
- public void setTimeout(Integer timeout){
- if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
- return;
- }
- Integer old = this.timeout;
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
- this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
- }
-
- private Integer buildTimeout(CompilationUnit astRoot) {
- return this.timeoutAdapter.getValue(astRoot);
- }
- //************************ comment *********************************
- public String getComment(){
- return this.comment;
- }
-
- public void setComment(String comment){
- if (this.attributeValueHasNotChanged(this.comment, comment)) {
- return;
- }
- String old = this.comment;
- this.comment = comment;
- this.commentAdapter.setValue(comment);
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
- private String buildComment(CompilationUnit astRoot) {
- return this.commentAdapter.getValue(astRoot);
- }
- //************************ readOnly *********************************
- public Boolean isReadOnly(){
- return this.readOnly;
- }
-
- public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
- return;
- }
- Boolean old = this.readOnly;
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
- }
-
- private Boolean buildReadOnly(CompilationUnit astRoot) {
- return this.readOnlyAdapter.getValue(astRoot);
- }
- // ********** NestableAnnotation implementation **********
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void initializeFrom(NestableAnnotation oldAnnotation) {
- HibernateSourceNamedQueryAnnotation oldQuery = (HibernateSourceNamedQueryAnnotation)
oldAnnotation;
- this.setName(oldQuery.getName());
- this.setQuery(oldQuery.getQuery());
- this.setFlushMode(oldQuery.getFlushMode());
- this.setCacheMode(oldQuery.getCacheMode());
- this.setCacheable(oldQuery.isCacheable());
- this.setComment(oldQuery.getComment());
- this.setFetchSize(oldQuery.getFetchSize());
- this.setTimeout(oldQuery.getTimeout());
- this.setCacheRegion(oldQuery.getCacheRegion());
- this.setReadOnly(oldQuery.isReadOnly());
- }
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void moveAnnotation(int newIndex) {
- this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
- }
-
- private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
- return (IndexedAnnotationAdapter) this.annotationAdapter;
- }
-
- public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent,
Member member) {
- return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__NAME);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__QUERY);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_QUERY__FLUSH_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_QUERY__CACHE_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean>
buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_QUERY__CACHEABLE);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__CACHE_REGION);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer>
buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_QUERY__FETCH_SIZE);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer>
buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_QUERY__TIMEOUT);
- }
-
- protected DeclarationAnnotationElementAdapter<String>
buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__COMMENT);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean>
buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_QUERY__READ_ONLY);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ********** static methods **********
-
- public static HibernateSourceNamedQueryAnnotation
createHibernateNamedQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
- }
-
- public static HibernateSourceNamedQueryAnnotation
createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
- IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
- IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member,
idaa);
- return new HibernateSourceNamedQueryAnnotation(parent, member, idaa,
annotationAdapter);
- }
-
- private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateNamedQueriesAdapter) {
- return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedQueriesAdapter,
index, Hibernate.NAMED_QUERY);
- }
-
-}
Modified:
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 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
import org.eclipse.jpt.core.utility.TextRange;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
/**
* @author Dmitry Geraskov
Modified:
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 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -30,6 +30,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
@@ -47,7 +48,9 @@
public static List<String> generatorClasses = new ArrayList<String>();
- //see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
+ /**
+ * @see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
+ */
static {
generatorClasses.add( "uuid"); //$NON-NLS-1$
generatorClasses.add( "hilo"); //$NON-NLS-1$
@@ -70,20 +73,14 @@
super(parent);
this.parameters = new ArrayList<JavaParameter>();
}
-
- public int getDefaultInitialValue() {
- return GenericGenerator.DEFAULT_INITIAL_VALUE;
- }
protected GenericGeneratorAnnotation getResourceGenerator() {
return this.generatorResource;
}
public void initialize(GenericGeneratorAnnotation generator) {
- generatorResource = generator;
+ this.generatorResource = generator;
this.name = generator.getName();
- this.specifiedInitialValue = generator.getInitialValue();
- this.specifiedAllocationSize = generator.getAllocationSize();
this.strategy = generator.getStrategy();
this.initializeParameters();
}
@@ -91,8 +88,6 @@
public void update(GenericGeneratorAnnotation generator) {
this.generatorResource = generator;
this.setName_(generator.getName());
- this.setSpecifiedInitialValue_(generator.getInitialValue());
- this.setSpecifiedAllocationSize_(generator.getAllocationSize());
this.setSpecifiedStrategy_(generator.getStrategy());
this.updateParameters();
this.getPersistenceUnit().addGenerator(this);
@@ -105,20 +100,6 @@
this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
}
- public void setSpecifiedInitialValue(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.generatorResource.setInitialValue(specifiedInitialValue);
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old,
specifiedInitialValue);
- }
-
- public void setSpecifiedAllocationSize(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.generatorResource.setAllocationSize(specifiedAllocationSize);
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old,
specifiedAllocationSize);
- }
-
public TextRange getSelectionTextRange(CompilationUnit astRoot) {
return this.generatorResource.getTextRange(astRoot);
}
@@ -300,5 +281,10 @@
parameter.initialize(resourceParameter);
return parameter;
}
+
+ public int getDefaultInitialValue() {
+ return GenericGenerator.DEFAULT_INITIAL_VALUE;
+ }
+
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java
(from rev 16283,
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/resource/java/GenericGeneratorAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+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
+ NestableAnnotation, 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"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterator<ParameterAnnotation> parameters();
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ int parametersSize();
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ ParameterAnnotation parameterAt(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ int indexOfParameter(ParameterAnnotation parameter);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ ParameterAnnotation addParameter(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ void removeParameter(int index);
+
+ /**
+ * 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);
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
(from rev 16283,
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/resource/java/GenericGeneratorAnnotationImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,384 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+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.AnnotationContainer;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+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.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorAnnotationImpl extends SourceAnnotation<Member>
+ implements GenericGeneratorAnnotation {
+
+ private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String>
strategyDeclarationAdapter;
+ private final AnnotationElementAdapter<String> strategyAdapter;
+ private String strategy;
+
+ final Vector<NestableParameterAnnotation> parameters = new
Vector<NestableParameterAnnotation>();
+ final ParametersAnnotationContainer parametersContainer = new
ParametersAnnotationContainer();
+
+ /**
+ * @param parent
+ * @param member
+ */
+ public GenericGeneratorAnnotationImpl(JavaResourceNode parent, Member member,
+ DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
nameDeclarationAdapter);
+ this.strategyDeclarationAdapter = this.buildStrategyAdapter(daa);
+ this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
strategyDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.name(astRoot);
+ this.strategy = this.strategy(astRoot);
+ AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ AnnotationContainerTools.update(this.parametersContainer, 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(nameDeclarationAdapter, astRoot);
+ }
+
+ public TextRange getStrategyTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(strategyDeclarationAdapter, astRoot);
+ }
+
+ public Integer getAllocationSize() {
+ return null;
+ }
+
+ public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public Integer getInitialValue() {
+ return null;
+ }
+
+ public TextRange getInitialValueTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public void setAllocationSize(Integer allocationSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setInitialValue(Integer initialValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ********** java annotations -> persistence model **********
+ protected String strategy(CompilationUnit astRoot) {
+ //TODO: get Generator instead of String
+ //use buildJavaGenericGenerator method before this will be done
+ return this.strategyAdapter.getValue(astRoot);
+ }
+
+ protected String name(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+
+ //************************ parameters ***********************
+
+ public NestableParameterAnnotation addParameter(int index) {
+ return (NestableParameterAnnotation)
AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation addParameterInternal() {
+ NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
+ this.parameters.add(parameter);
+ return parameter;
+ }
+
+ NestableParameterAnnotation buildParameter(int index) {
+ return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member,
this.daa, index);
+ }
+
+ ListIterator<NestableParameterAnnotation> nestableParameters() {
+ return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
+ }
+
+ void parameterAdded(int index, NestableParameterAnnotation parameter) {
+ this.fireItemAdded(PARAMETERS_LIST, index, parameter);
+ }
+
+ NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.parameters, targetIndex,
sourceIndex).get(targetIndex);
+ }
+
+ void parameterMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public int indexOfParameter(ParameterAnnotation parameter) {
+ return this.parameters.indexOf(parameter);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.parametersContainer);
+ }
+
+ public ParameterAnnotation parameterAt(int index) {
+ return this.parameters.get(index);
+ }
+
+ public ListIterator<ParameterAnnotation> parameters() {
+ return new CloneListIterator<ParameterAnnotation>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ public void removeParameter(int index) {
+ AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation removeParameterInternal(int index) {
+ return this.parameters.remove(index);
+ }
+
+ void parameterRemoved(int index, NestableParameterAnnotation parameter) {
+ this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
+ }
+
+ // ********** NestableAnnotation implementation **********
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ GenericGeneratorAnnotation oldGenericGenerator = (GenericGeneratorAnnotation)
oldAnnotation;
+ this.setName(oldGenericGenerator.getName());
+ this.setStrategy(oldGenericGenerator.getStrategy());
+ //this.setAllocationSize(oldGenericGenerator.getAllocationSize());
+ //this.setInitialValue(oldGenericGenerator.getInitialValue());
+ for (ParameterAnnotation oldParameter :
CollectionTools.iterable(oldGenericGenerator.parameters())) {
+ NestableParameterAnnotation newParameter =
this.addParameter(oldGenericGenerator.indexOfParameter(oldParameter));
+ newParameter.initializeFrom((NestableParameterAnnotation) oldParameter);
+ }
+ }
+
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ super.toString(sb);
+ sb.append(name);
+ }
+
+ private DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa,
Hibernate.GENERIC_GENERATOR__NAME, false);
+ }
+
+ private DeclarationAnnotationElementAdapter<String>
buildStrategyAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa,
Hibernate.GENERIC_GENERATOR__STRATEGY, false);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the override's join columns
+ */
+ class ParametersAnnotationContainer
+ implements AnnotationContainer<NestableParameterAnnotation>
+ {
+ public String getContainerAnnotationName() {
+ return GenericGeneratorAnnotationImpl.this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.GENERIC_GENERATOR__PARAMETERS;
+ }
+
+ public String getNestableAnnotationName() {
+ return ParameterAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
+ return GenericGeneratorAnnotationImpl.this.nestableParameters();
+ }
+
+ public int nestedAnnotationsSize() {
+ return GenericGeneratorAnnotationImpl.this.parametersSize();
+ }
+
+ public NestableParameterAnnotation addNestedAnnotationInternal() {
+ return GenericGeneratorAnnotationImpl.this.addParameterInternal();
+ }
+
+ public void nestedAnnotationAdded(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
+ }
+
+ public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
+ return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex,
sourceIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
+ }
+
+ public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
+ return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterRemoved(index, nestedAnnotation);
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+ }
+
+ public static GenericGeneratorAnnotation createNestedGenericGenerator(
+ JavaResourceNode parent, Member member,
+ int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member,
idaa);
+ return new GenericGeneratorAnnotationImpl(parent, member, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateGenericGeneratorsAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateGenericGeneratorsAdapter,
index, Hibernate.GENERIC_GENERATOR);
+ }
+
+ 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,
+ DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member
member) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return GenericGeneratorAnnotation.ANNOTATION_NAME;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
+ IAnnotation arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember arg0) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorsAnnotation extends
+ ContainerAnnotation<GenericGeneratorAnnotation> {
+
+ String ANNOTATION_NAME = Hibernate.GENERIC_GENERATORS;
+
+ String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.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/resource/java/HibernateNamedNativeQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -12,7 +12,6 @@
import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java
(from rev 16544,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Corresponds to the Hibernate annotation
+ * org.hibernate.annotations.NamedNativeQuery
+ */
+public interface HibernateNamedNativeQueryAnnotation
+ extends NestableNamedNativeQueryAnnotation, HibernateQueryAnnotation {
+ //replace with Hibernate annotation
+ String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERY;
+
+ //************************ callable *********************************
+ Boolean isCallable();
+ void setCallable(Boolean value);
+ String CALLABLE_PROPERTY = "callable"; //$NON-NLS-1$
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -16,7 +16,6 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -12,7 +12,6 @@
import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryAnnotation;
/**
* @author Dmitry Geraskov
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -16,7 +16,6 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java
(from rev 16544,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Interface contains Hibernate specific attributes.
+ */
+public interface HibernateQueryAnnotation {
+
+ //************************ flushMode *********************************
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ FlushModeType getFlushMode();
+ String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setFlushMode(FlushModeType flushMode);
+
+ /**
+ * Return the {@link TextRange} for the 'flushMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getFlushModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheMode *********************************
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ CacheModeType getCacheMode();
+ String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setCacheMode(CacheModeType cacheMode);
+
+ /**
+ * Return the {@link TextRange} for the 'cacheMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getCacheModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheable *********************************
+ Boolean isCacheable();
+ void setCacheable(Boolean value);
+ String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
+
+ //************************ cacheRegion *********************************
+ String getCacheRegion();
+ void setCacheRegion(String value);
+ String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
+
+ //************************ fetchSize *********************************
+ Integer getFetchSize();
+ void setFetchSize(Integer value);
+ String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
+
+ //************************ timeout *********************************
+ Integer getTimeout();
+ void setTimeout(Integer value);
+ String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
+
+ //************************ comment *********************************
+ String getComment();
+ void setComment(String value);
+ String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
+
+ //************************ readOnly *********************************
+ Boolean isReadOnly();
+ void setReadOnly(Boolean value);
+ String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -23,8 +23,6 @@
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
(from rev 16544,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,615 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+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.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedNativeQueryAnnotation extends
SourceAnnotation<Member> implements
+ HibernateNamedNativeQueryAnnotation {
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
+ private final AnnotationElementAdapter<String> queryAdapter;
+ private String query;
+
+ private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> flushModeAdapter;
+ private FlushModeType flushMode;
+
+ private final DeclarationAnnotationElementAdapter<String>
cacheModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheModeAdapter;
+ private CacheModeType cacheMode;
+
+ private final DeclarationAnnotationElementAdapter<Boolean>
cacheableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> cacheableAdapter;
+ private Boolean cacheable;
+
+ private final DeclarationAnnotationElementAdapter<String>
cacheRegionDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheRegionAdapter;
+ private String cacheRegion;
+
+ private final DeclarationAnnotationElementAdapter<Integer>
fetchSizeDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
+ private Integer fetchSize;
+
+ private final DeclarationAnnotationElementAdapter<Integer>
timeoutDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> timeoutAdapter;
+ private Integer timeout;
+
+ private final DeclarationAnnotationElementAdapter<String>
commentDeclarationAdapter;
+ private final AnnotationElementAdapter<String> commentAdapter;
+ private String comment;
+
+ private final DeclarationAnnotationElementAdapter<Boolean>
readOnlyDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
+ private Boolean readOnly;
+
+ private final DeclarationAnnotationElementAdapter<Boolean>
callableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> callableAdapter;
+ private Boolean callable;
+
+ private final DeclarationAnnotationElementAdapter<String>
resultClassDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultClassAdapter;
+ private String resultClass;
+
+ private String fullyQualifiedResultClassName;
+
+ private final DeclarationAnnotationElementAdapter<String>
resultSetMappingDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultSetMappingAdapter;
+ private String resultSetMapping;
+
+ HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
+ this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
flushModeDeclarationAdapter);
+ this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
+ this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
cacheModeDeclarationAdapter);
+ this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
+ this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
cacheableDeclarationAdapter);
+ this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
+ this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
+ this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
+ this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
fetchSizeDeclarationAdapter);
+ this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
+ this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
timeoutDeclarationAdapter);
+ this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
+ this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
commentDeclarationAdapter);
+ this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
readOnlyDeclarationAdapter);
+ this.callableDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.callableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
callableDeclarationAdapter);
+ this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa);
+ this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter);
+ this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
+ this.resultSetMappingAdapter =
this.buildAdapter(this.resultSetMappingDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ this.flushMode = this.buildFlushMode(astRoot);
+ this.cacheMode = this.buildCacheMode(astRoot);
+ this.cacheable = this.buildCacheable(astRoot);
+ this.cacheRegion = this.buildCacheRegion(astRoot);
+ this.fetchSize = this.buildFetchSize(astRoot);
+ this.timeout = this.buildTimeout(astRoot);
+ this.comment = this.buildComment(astRoot);
+ this.readOnly = this.buildReadOnly(astRoot);
+ this.callable = this.buildCallable(astRoot);
+ this.resultClass = this.buildResultClass(astRoot);
+ this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot);
+ this.resultSetMapping = this.buildResultSetMapping(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ this.setCallable(this.buildCallable(astRoot));
+ this.setResultClass(this.buildResultClass(astRoot));
+ this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
+ this.setResultSetMapping(this.buildResultSetMapping(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ // ********** BaseNamedNativeQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_NATIVE_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return EmptyListIterator.instance();
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return EmptyListIterator.instance();
+ }
+
+ public int hintsSize() {
+ return 0;
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return -1;
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.hintsContainer);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ // ******************** HibernateNamedNativeQueryAnnotation implementation
*************
+ // ***** flushMode
+
+ public FlushModeType getFlushMode() {
+ return flushMode;
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
+ }
+ FlushModeType old = this.flushMode;
+ this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
+ }
+
+ private FlushModeType buildFlushMode(CompilationUnit astRoot) {
+ return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
+ }
+
+ // ***** caheMode
+
+ public CacheModeType getCacheMode() {
+ return cacheMode;
+ }
+
+ public void setCacheMode(CacheModeType cacheMode) {
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
+ }
+ CacheModeType old = this.cacheMode;
+ this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
+ }
+
+ private CacheModeType buildCacheMode(CompilationUnit astRoot) {
+ return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
+ }
+
+ //************************ cacheable *********************************
+ public Boolean isCacheable(){
+ return this.cacheable;
+ }
+
+ public void setCacheable(Boolean cacheable){
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
+ }
+ Boolean old = this.cacheable;
+ this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
+ this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
+ }
+
+ private Boolean buildCacheable(CompilationUnit astRoot) {
+ return this.cacheableAdapter.getValue(astRoot);
+ }
+
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return this.cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion){
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
+ }
+ String old = this.cacheRegion;
+ this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
+ this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
+ }
+
+ private String buildCacheRegion(CompilationUnit astRoot) {
+ return this.cacheRegionAdapter.getValue(astRoot);
+ }
+ //************************ fetchSize *********************************
+ public Integer getFetchSize(){
+ return this.fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize){
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
+ }
+ Integer old = this.fetchSize;
+ this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
+ this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
+ }
+
+ private Integer buildFetchSize(CompilationUnit astRoot) {
+ return this.fetchSizeAdapter.getValue(astRoot);
+ }
+ //************************ timeout *********************************
+ public Integer getTimeout(){
+ return this.timeout;
+ }
+ public void setTimeout(Integer timeout){
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
+ }
+ Integer old = this.timeout;
+ this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
+ this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
+ }
+
+ private Integer buildTimeout(CompilationUnit astRoot) {
+ return this.timeoutAdapter.getValue(astRoot);
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return this.comment;
+ }
+
+ public void setComment(String comment){
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
+ }
+ String old = this.comment;
+ this.comment = comment;
+ this.commentAdapter.setValue(comment);
+ this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
+ }
+
+ private String buildComment(CompilationUnit astRoot) {
+ return this.commentAdapter.getValue(astRoot);
+ }
+ //************************ readOnly *********************************
+ public Boolean isReadOnly(){
+ return this.readOnly;
+ }
+
+ public void setReadOnly(Boolean readOnly){
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
+ Boolean old = this.readOnly;
+ this.readOnly = readOnly;
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ }
+
+ private Boolean buildReadOnly(CompilationUnit astRoot) {
+ return this.readOnlyAdapter.getValue(astRoot);
+ }
+ //************************ callable *********************************
+ public Boolean isCallable(){
+ return this.callable;
+ }
+
+ public void setCallable(Boolean callable){
+ if (this.attributeValueHasNotChanged(this.callable, callable)) {
+ return;
+ }
+ Boolean old = this.callable;
+ this.callable = callable;
+ this.callableAdapter.setValue(callable);
+ this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
+ }
+
+ private Boolean buildCallable(CompilationUnit astRoot) {
+ return this.callableAdapter.getValue(astRoot);
+ }
+ // ***** result class
+ public String getResultClass() {
+ return this.resultClass;
+ }
+
+ public void setResultClass(String resultClass) {
+ if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
+ return;
+ }
+ String old = this.resultClass;
+ this.resultClass = resultClass;
+ this.resultClassAdapter.setValue(resultClass);
+ this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
+ }
+
+ private String buildResultClass(CompilationUnit astRoot) {
+ return this.resultClassAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultClassTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot);
+ }
+
+ // ***** fully-qualified result class name
+ public String getFullyQualifiedResultClassName() {
+ return this.fullyQualifiedResultClassName;
+ }
+
+ private void setFullyQualifiedResultClassName(String name) {
+ String old = this.fullyQualifiedResultClassName;
+ this.fullyQualifiedResultClassName = name;
+ this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
+ }
+
+ private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
+ return (this.resultClass == null) ? null :
JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
+ }
+
+ // ***** result set mapping
+ public String getResultSetMapping() {
+ return this.resultSetMapping;
+ }
+
+ public void setResultSetMapping(String resultSetMapping) {
+ if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
+ return;
+ }
+ String old = this.resultSetMapping;
+ this.resultSetMapping = resultSetMapping;
+ this.resultSetMappingAdapter.setValue(resultSetMapping);
+ this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
+ }
+
+ private String buildResultSetMapping(CompilationUnit astRoot) {
+ return this.resultSetMappingAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot);
+ }
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ HibernateSourceNamedNativeQueryAnnotation oldQuery =
(HibernateSourceNamedNativeQueryAnnotation) oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ this.setFlushMode(oldQuery.getFlushMode());
+ this.setCacheMode(oldQuery.getCacheMode());
+ this.setCacheable(oldQuery.isCacheable());
+ this.setComment(oldQuery.getComment());
+ this.setFetchSize(oldQuery.getFetchSize());
+ this.setTimeout(oldQuery.getTimeout());
+ this.setCacheRegion(oldQuery.getCacheRegion());
+ this.setReadOnly(oldQuery.isReadOnly());
+ this.setCallable(oldQuery.isCallable());
+ this.setResultClass(oldQuery.getResultClass());
+ this.setResultSetMapping(oldQuery.getResultSetMapping());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static HibernateNamedNativeQueryAnnotation
createNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__NAME);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__QUERY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__FLUSH_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHE_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean>
buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHEABLE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CACHE_REGION);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer>
buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__FETCH_SIZE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer>
buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__TIMEOUT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__COMMENT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean>
buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__READ_ONLY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean>
buildCallableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__CALLABLE);
+ }
+
+
+ private DeclarationAnnotationElementAdapter<String>
buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__RESULT_CLASS,
SimpleTypeStringExpressionConverter.instance());
+ }
+
+ private DeclarationAnnotationElementAdapter<String>
buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+ // ********** static methods **********
+
+ public static HibernateSourceNamedNativeQueryAnnotation
createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public static HibernateSourceNamedNativeQueryAnnotation
createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member,
idaa);
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa,
annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateNamedNativeQueriesAdapter) {
+ return new
NestedIndexedDeclarationAnnotationAdapter(hibernateNamedNativeQueriesAdapter, index,
Hibernate.NAMED_NATIVE_QUERY);
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-23
11:19:10 UTC (rev 16746)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -23,7 +23,6 @@
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
(from rev 16544,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,490 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+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.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+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.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
+ implements HibernateNamedQueryAnnotation {
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
+ private final AnnotationElementAdapter<String> queryAdapter;
+ private String query;
+
+ private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> flushModeAdapter;
+ private FlushModeType flushMode;
+
+ private final DeclarationAnnotationElementAdapter<String>
cacheModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheModeAdapter;
+ private CacheModeType cacheMode;
+
+ private final DeclarationAnnotationElementAdapter<Boolean>
cacheableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> cacheableAdapter;
+ private Boolean cacheable;
+
+ private final DeclarationAnnotationElementAdapter<String>
cacheRegionDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheRegionAdapter;
+ private String cacheRegion;
+
+ private final DeclarationAnnotationElementAdapter<Integer>
fetchSizeDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
+ private Integer fetchSize;
+
+ private final DeclarationAnnotationElementAdapter<Integer>
timeoutDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> timeoutAdapter;
+ private Integer timeout;
+
+ private final DeclarationAnnotationElementAdapter<String>
commentDeclarationAdapter;
+ private final AnnotationElementAdapter<String> commentAdapter;
+ private String comment;
+
+ private final DeclarationAnnotationElementAdapter<Boolean>
readOnlyDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
+ private Boolean readOnly;
+
+ HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
+ this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
flushModeDeclarationAdapter);
+ this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
+ this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
cacheModeDeclarationAdapter);
+ this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
+ this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
cacheableDeclarationAdapter);
+ this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
+ this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
+ this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
+ this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
fetchSizeDeclarationAdapter);
+ this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
+ this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member,
timeoutDeclarationAdapter);
+ this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
+ this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member,
commentDeclarationAdapter);
+ this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
readOnlyDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ this.flushMode = this.buildFlushMode(astRoot);
+ this.cacheMode = this.buildCacheMode(astRoot);
+ this.cacheable = this.buildCacheable(astRoot);
+ this.cacheRegion = this.buildCacheRegion(astRoot);
+ this.fetchSize = this.buildFetchSize(astRoot);
+ this.timeout = this.buildTimeout(astRoot);
+ this.comment = this.buildComment(astRoot);
+ this.readOnly = this.buildReadOnly(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ // ********** BaseNamedQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return EmptyListIterator.instance();
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return EmptyListIterator.instance();
+ }
+
+ public int hintsSize() {
+ return 0;
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return -1;
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.hintsContainer);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ // ******************** HibernateNamedQueryAnnotation implementation *************
+ // ***** flushMode
+
+ public FlushModeType getFlushMode() {
+ return flushMode;
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
+ }
+ FlushModeType old = this.flushMode;
+ this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
+ }
+
+ private FlushModeType buildFlushMode(CompilationUnit astRoot) {
+ return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
+ }
+
+ // ***** caheMode
+
+ public CacheModeType getCacheMode() {
+ return cacheMode;
+ }
+
+ public void setCacheMode(CacheModeType cacheMode) {
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
+ }
+ CacheModeType old = this.cacheMode;
+ this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
+ }
+
+ private CacheModeType buildCacheMode(CompilationUnit astRoot) {
+ return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
+ }
+
+ //************************ cacheable *********************************
+ public Boolean isCacheable(){
+ return this.cacheable;
+ }
+
+ public void setCacheable(Boolean cacheable){
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
+ }
+ Boolean old = this.cacheable;
+ this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
+ this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
+ }
+
+ private Boolean buildCacheable(CompilationUnit astRoot) {
+ return this.cacheableAdapter.getValue(astRoot);
+ }
+
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return this.cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion){
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
+ }
+ String old = this.cacheRegion;
+ this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
+ this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
+ }
+
+ private String buildCacheRegion(CompilationUnit astRoot) {
+ return this.cacheRegionAdapter.getValue(astRoot);
+ }
+ //************************ fetchSize *********************************
+ public Integer getFetchSize(){
+ return this.fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize){
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
+ }
+ Integer old = this.fetchSize;
+ this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
+ this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
+ }
+
+ private Integer buildFetchSize(CompilationUnit astRoot) {
+ return this.fetchSizeAdapter.getValue(astRoot);
+ }
+ //************************ timeout *********************************
+ public Integer getTimeout(){
+ return this.timeout;
+ }
+ public void setTimeout(Integer timeout){
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
+ }
+ Integer old = this.timeout;
+ this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
+ this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
+ }
+
+ private Integer buildTimeout(CompilationUnit astRoot) {
+ return this.timeoutAdapter.getValue(astRoot);
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return this.comment;
+ }
+
+ public void setComment(String comment){
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
+ }
+ String old = this.comment;
+ this.comment = comment;
+ this.commentAdapter.setValue(comment);
+ this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
+ }
+
+ private String buildComment(CompilationUnit astRoot) {
+ return this.commentAdapter.getValue(astRoot);
+ }
+ //************************ readOnly *********************************
+ public Boolean isReadOnly(){
+ return this.readOnly;
+ }
+
+ public void setReadOnly(Boolean readOnly){
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
+ Boolean old = this.readOnly;
+ this.readOnly = readOnly;
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ }
+
+ private Boolean buildReadOnly(CompilationUnit astRoot) {
+ return this.readOnlyAdapter.getValue(astRoot);
+ }
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ HibernateSourceNamedQueryAnnotation oldQuery = (HibernateSourceNamedQueryAnnotation)
oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ this.setFlushMode(oldQuery.getFlushMode());
+ this.setCacheMode(oldQuery.getCacheMode());
+ this.setCacheable(oldQuery.isCacheable());
+ this.setComment(oldQuery.getComment());
+ this.setFetchSize(oldQuery.getFetchSize());
+ this.setTimeout(oldQuery.getTimeout());
+ this.setCacheRegion(oldQuery.getCacheRegion());
+ this.setReadOnly(oldQuery.isReadOnly());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent,
Member member) {
+ return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__NAME);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__QUERY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_QUERY__FLUSH_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter,
Hibernate.NAMED_QUERY__CACHE_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean>
buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_QUERY__CACHEABLE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__CACHE_REGION);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer>
buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_QUERY__FETCH_SIZE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer>
buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter,
Hibernate.NAMED_QUERY__TIMEOUT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String>
buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter,
Hibernate.NAMED_QUERY__COMMENT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean>
buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter,
Hibernate.NAMED_QUERY__READ_ONLY);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+ // ********** static methods **********
+
+ public static HibernateSourceNamedQueryAnnotation
createHibernateNamedQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public static HibernateSourceNamedQueryAnnotation
createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member,
idaa);
+ return new HibernateSourceNamedQueryAnnotation(parent, member, idaa,
annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateNamedQueriesAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedQueriesAdapter,
index, Hibernate.NAMED_QUERY);
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2009-07-23
13:40:36 UTC (rev 16747)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.resource.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+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.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class SourceGenericGeneratorsAnnotation extends SourceAnnotation<Member>
implements
+ GenericGeneratorsAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final Vector<GenericGeneratorAnnotation> genericGenerators = new
Vector<GenericGeneratorAnnotation>();
+
+
+ public SourceGenericGeneratorsAnnotation(JavaResourceNode parent, Member member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ AnnotationContainerTools.initialize(this, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.genericGenerators);
+ }
+
+ // ********** AnnotationContainer implementation **********
+
+ public String getContainerAnnotationName() {
+ return this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.GENERIC_GENERATORS__VALUE;
+ }
+
+ public String getNestableAnnotationName() {
+ return GenericGeneratorAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<GenericGeneratorAnnotation> nestedAnnotations() {
+ return new
CloneListIterator<GenericGeneratorAnnotation>(this.genericGenerators);
+ }
+
+ public int nestedAnnotationsSize() {
+ return this.genericGenerators.size();
+ }
+
+ public GenericGeneratorAnnotation addNestedAnnotationInternal() {
+ GenericGeneratorAnnotation genericGenerator =
this.buildGenericGenerator(this.genericGenerators.size());
+ this.genericGenerators.add(genericGenerator);
+ return genericGenerator;
+ }
+
+ private GenericGeneratorAnnotation buildGenericGenerator(int index) {
+ return GenericGeneratorAnnotationImpl.createNestedGenericGenerator(this, member, index,
this.daa);
+ }
+
+ public void nestedAnnotationAdded(int index, GenericGeneratorAnnotation
nestedAnnotation) {
+ this.fireItemAdded(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
+ }
+
+ public GenericGeneratorAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
+ return CollectionTools.move(this.genericGenerators, targetIndex,
sourceIndex).get(targetIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
+ }
+
+ public GenericGeneratorAnnotation removeNestedAnnotationInternal(int index) {
+ return this.genericGenerators.remove(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, GenericGeneratorAnnotation
nestedAnnotation) {
+ this.fireItemRemoved(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
+ }
+
+ public static class GenericGeneratorsAnnotationDefinition implements
AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new
GenericGeneratorsAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private GenericGeneratorsAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member)
{
+ return new SourceGenericGeneratorsAnnotation(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation
jdtAnnotation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return GenericGeneratorsAnnotation.ANNOTATION_NAME;
+ }
+
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native