Author: dgeraskov
Date: 2009-07-13 06:17:39 -0400 (Mon, 13 Jul 2009)
New Revision: 16544
Added:
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/HibernateNamedNativeQueryAnnotation.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/HibernateNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.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/resource/java/HibernateNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.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.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties
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/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.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/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java
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/HibernateNamedQueriesAnnotation.java
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.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4521
Hibernate @NamedNativeQuery/Queries support
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties 2009-07-13
10:17:39 UTC (rev 16544)
@@ -3,5 +3,4 @@
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/,\
plugin.properties
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-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -15,9 +15,11 @@
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.HibernateNamedQueryAnnotationDefinition;
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;
/**
* @author Dmitry Geraskov
@@ -51,6 +53,8 @@
definitions.add(GenericGeneratorAnnotationDefinition.instance());
definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueriesAnnotationDefinition.instance());
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -22,8 +22,11 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
@@ -57,6 +60,10 @@
public HibernateNamedQuery buildHibernateNamedQuery(JavaJpaContextNode parent) {
return new HibernateNamedQueryImpl(parent);
}
+
+ public HibernateNamedNativeQuery buildHibernateNamedNativeQuery(JavaJpaContextNode
parent) {
+ return new HibernateNamedNativeQueryImpl(parent);
+ }
public JavaParameter buildJavaParameter(JavaGenericGeneratorImpl
javaGenericGeneratorImpl) {
return new HibernateJavaParameter(javaGenericGeneratorImpl);
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -1,293 +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;
-
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateNamedQueryImpl extends GenericJavaNamedQuery
- implements HibernateNamedQuery {
-
- private FlushModeType specifiedFlushMode;
-
- private CacheModeType specifiedCacheMode;
-
- private Boolean specifiedCacheable;
-
- private String specifiedCacheRegion;
-
- private Integer specifiedFetchSize;
-
- private Integer specifiedTimeout;
-
- private String specifiedComment;
-
- private Boolean specifiedReadOnly;
-
- /**
- * @param parent
- */
- public HibernateNamedQueryImpl(JavaJpaContextNode parent) {
- super(parent);
- }
-
- public void initialize(HibernateNamedQueryAnnotation resourceQuery) {
- this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
- this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
- this.specifiedCacheable = resourceQuery.isCacheable();
- this.specifiedCacheRegion = resourceQuery.getCacheRegion();
- this.specifiedFetchSize = resourceQuery.getFetchSize();
- this.specifiedTimeout = resourceQuery.getTimeout();
- this.specifiedComment = resourceQuery.getComment();
- this.specifiedReadOnly = resourceQuery.isReadOnly();
- super.initialize(resourceQuery);
- }
-
- public void update(HibernateNamedQueryAnnotation resourceQuery) {
- this.setFlushMode_(resourceQuery.getFlushMode());
- this.setCacheMode_ (resourceQuery.getCacheMode());
- this.setSpecifiedCacheable_(resourceQuery.isCacheable());
- this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
- this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
- this.setSpecifiedTimeout_(resourceQuery.getTimeout());
- this.setSpecifiedComment_(resourceQuery.getComment());
- this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
- super.update(resourceQuery);
- }
-
- private CacheModeType getResourceCacheMode(HibernateNamedQueryAnnotation resourceQuery)
{
- return CacheModeType.fromJavaAnnotationValue(resourceQuery);
- }
-
- private FlushModeType getResourceFlushMode(HibernateNamedQueryAnnotation resourceQuery)
{
- return FlushModeType.fromJavaAnnotationValue(resourceQuery);
- }
-
- @Override
- protected HibernateNamedQueryAnnotation getResourceQuery() {
- return (HibernateNamedQueryAnnotation) super.getResourceQuery();
- }
-
- // ****** flushMode
- public FlushModeType getFlushMode() {
- return getSpecifiedFlushMode() == null ? getDefaultFlushMode() :
getSpecifiedFlushMode();
- }
-
- public FlushModeType getSpecifiedFlushMode() {
- return specifiedFlushMode;
- }
-
- public FlushModeType getDefaultFlushMode() {
- return HibernateNamedQuery.DEFAULT_FLUSH_MODE_TYPE;
- }
-
- public void setSpecifiedFlushMode(FlushModeType flushMode) {
- FlushModeType oldFlushMode = this.specifiedFlushMode;
- this.specifiedFlushMode = flushMode;
- getResourceQuery().setFlushMode(flushMode);
- firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
- }
-
- protected void setFlushMode_(FlushModeType flushMode) {
- FlushModeType oldFlushMode = this.specifiedFlushMode;
- this.specifiedFlushMode = flushMode;
- firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
- }
- // ****** cacheMode
- public CacheModeType getCacheMode() {
- return getSpecifiedCacheMode() == null ? getDefaultCacheMode() :
getSpecifiedCacheMode();
- }
-
- public CacheModeType getDefaultCacheMode() {
- return HibernateNamedQuery.DEFAULT_CACHE_MODE_TYPE;
- }
-
- public CacheModeType getSpecifiedCacheMode() {
- return specifiedCacheMode;
- }
-
- public void setSpecifiedCacheMode(CacheModeType cacheMode) {
- CacheModeType oldCacheMode = this.specifiedCacheMode;
- this.specifiedCacheMode = cacheMode;
- getResourceQuery().setCacheMode(cacheMode);
- firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
- }
-
- public void setCacheMode_(CacheModeType cacheMode) {
- CacheModeType oldCacheMode = this.specifiedCacheMode;
- this.specifiedCacheMode = cacheMode;
- firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
- }
- //************************ cacheable *********************************
- public boolean isCacheable(){
- return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
- : this.getSpecifiedCacheable().booleanValue();
- }
-
- public Boolean getSpecifiedCacheable(){
- return this.specifiedCacheable;
- }
-
- public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
- Boolean oldSpecifiedCacheable = this.specifiedCacheable;
- this.specifiedCacheable = newSpecifiedCacheable;
- this.getResourceQuery().setCacheable(newSpecifiedCacheable);
- firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
-
- }
-
- public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
- Boolean oldSpecifiedCacheable = this.specifiedCacheable;
- this.specifiedCacheable = newSpecifiedCacheable;
- firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
- }
-
- public boolean isDefaultCacheable() {
- return HibernateNamedQuery.DEFAULT_CACHEABLE;
- }
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
- : getSpecifiedCacheRegion());
- }
- public String getSpecifiedCacheRegion(){
- return this.specifiedCacheRegion;
- }
-
- public void setSpecifiedCacheRegion(String cacheRegion){
- String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
- this.specifiedCacheRegion = cacheRegion;
- this.getResourceQuery().setCacheRegion(cacheRegion);
- firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
- }
-
- public void setSpecifiedCacheRegion_(String cacheRegion){
- String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
- this.specifiedCacheRegion = cacheRegion;
- firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
- }
-
- public String getDefaultCacheRegion(){
- return HibernateNamedQuery.DEFAULT_CACHE_REGION;
- }
- //************************ fetchSize *********************************
- public int getFetchSize(){
- return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
- : getSpecifiedFetchSize().intValue());
- }
-
- public Integer getSpecifiedFetchSize(){
- return this.specifiedFetchSize;
- }
-
- public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
- Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
- this.specifiedFetchSize = newSpecifiedFetchSize;
- this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
- firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize,
newSpecifiedFetchSize);
- }
-
- public void setSpecifiedFetchSize_(Integer fetchSize){
- Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
- this.specifiedFetchSize = fetchSize;
- firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
- }
-
- public int getDefaultFetchSize(){
- return HibernateNamedQuery.DEFAULT_FETCH_SIZE;
- }
- //************************ timeout *********************************
- public int getTimeout(){
- return (getSpecifiedTimeout() == null ? getDefaultTimeout()
- : getSpecifiedTimeout().intValue());
- }
-
- public Integer getSpecifiedTimeout(){
- return this.specifiedTimeout;
- }
-
- public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
- Integer oldSpecifiedTimeout = this.specifiedTimeout;
- this.specifiedTimeout = newSpecifiedTimeout;
- this.getResourceQuery().setTimeout(newSpecifiedTimeout);
- firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout,
newSpecifiedTimeout);
- }
-
- public void setSpecifiedTimeout_(Integer timeout){
- Integer oldSpecifiedTimeout = this.specifiedTimeout;
- this.specifiedTimeout = timeout;
- firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
- }
-
- public int getDefaultTimeout(){
- return HibernateNamedQuery.DEFAULT_TIMEOUT;
- }
- //************************ comment *********************************
- public String getComment(){
- return (getSpecifiedComment() == null ? getDefaultComment()
- : getSpecifiedComment());
- }
- public String getSpecifiedComment(){
- return this.specifiedComment;
- }
-
- public void setSpecifiedComment(String newSpecifiedComment){
- String oldSpecifiedComment = this.specifiedComment;
- this.specifiedComment = newSpecifiedComment;
- this.getResourceQuery().setComment(newSpecifiedComment);
- firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment,
newSpecifiedComment);
- }
-
- public void setSpecifiedComment_(String comment){
- String oldSpecifiedComment = this.specifiedComment;
- this.specifiedComment = comment;
- firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
- }
-
- public String getDefaultComment(){
- return HibernateNamedQuery.DEFAULT_COMMENT;
- }
-
- //************************ readOnly *********************************
- public boolean isReadOnly(){
- return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
- : getSpecifiedReadOnly().booleanValue());
- }
-
- public Boolean getSpecifiedReadOnly(){
- return this.specifiedReadOnly;
- }
-
- public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
- Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
- this.specifiedReadOnly = newSpecifiedReadOnly;
- this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
- firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly,
newSpecifiedReadOnly);
- }
-
- public void setSpecifiedReadOnly_(Boolean readOnly){
- Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
- this.specifiedReadOnly = readOnly;
- firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
- }
-
- public boolean isDefaultReadOnly(){
- return HibernateNamedQuery.DEFAULT_READ_ONLY;
- }
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -163,7 +163,6 @@
* @param value -
* property value
*/
- @SuppressWarnings("unchecked")
protected void putProperty(String key, Object value) {
String elKey = this.hibernateKeyFor(key);
if (value == null)
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-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -48,6 +48,25 @@
String NAMED_QUERIES = PACKAGE_ + "NamedQueries"; //$NON-NLS-1$
String NAMED_QUERIES__VALUE = "value"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY = PACKAGE_ + "NamedNativeQuery"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__NAME = "name"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__QUERY = "query"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__HINTS = "hints"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__FLUSH_MODE = "flushMode"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHE_MODE = "cacheMode"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHEABLE = "cacheable"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHE_REGION = "cacheRegion"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__FETCH_SIZE = "fetchSize"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__TIMEOUT = "timeout"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__COMMENT = "comment"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__READ_ONLY = "readOnly"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__RESULT_CLASS = "resultClass"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__RESULT_SET_MAPPING = "resultSetMapping";
//$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CALLABLE = "callable"; //$NON-NLS-1$
+
+ String NAMED_NATIVE_QUERIES = PACKAGE_ + "NamedNativeQueries"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERIES__VALUE = "value"; //$NON-NLS-1$
+
String FLUSH_MODE_TYPE = PACKAGE_ + "FlushModeType"; //$NON-NLS-1$
String FLUSH_MODE_TYPE_ = FLUSH_MODE_TYPE + '.';
String FLUSH_MODE_TYPE__ALWAYS = FLUSH_MODE_TYPE_ + "ALWAYS"; //$NON-NLS-1$
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-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -31,7 +31,9 @@
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.HibernateNamedNativeQueriesAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
@@ -44,9 +46,12 @@
protected final List<HibernateNamedQuery> hibernateNamedQueries;
+ protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
+
public HibernateJavaEntity(JavaPersistentType parent) {
super(parent);
this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
+ this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
}
@Override
@@ -54,6 +59,7 @@
super.initialize(resourcePersistentType);
this.initializeGenericGenerator();
this.initializeHibernateNamedQueries();
+ this.initializeHibernateNamedNativeQueries();
}
@Override
@@ -61,12 +67,16 @@
super.update(resourcePersistentType);
this.updateGenericGenerator();
this.updateHibernateNamedQueries();
+ this.updateHibernateNamedNativeQueries();
}
@SuppressWarnings("unchecked")
@Override
public Iterator<JavaQuery> queries() {
- return new CompositeIterator<JavaQuery>(super.queries(),
this.hibernateNamedQueries());
+ return new CompositeIterator<JavaQuery>(
+ super.queries(),
+ this.hibernateNamedQueries(),
+ this.hibernateNamedNativeQueries());
}
// ********************* GenericGenerator **************
@@ -76,7 +86,9 @@
return new CompositeIterator<String>(
new ArrayIterator<String>(Hibernate.GENERIC_GENERATOR,
Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES),
+ Hibernate.NAMED_QUERIES,
+ Hibernate.NAMED_NATIVE_QUERY,
+ Hibernate.NAMED_NATIVE_QUERIES),
super.correspondingAnnotationNames());
}
@@ -234,6 +246,88 @@
this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
}
+
+ // ********************* NamedNativeQuery **************
+ public ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries() {
+ return new
CloneListIterator<HibernateNamedNativeQuery>(this.hibernateNamedNativeQueries);
+ }
+
+ public int hibernateNamedNativeQueriesSize() {
+ return this.hibernateNamedNativeQueries.size();
+ }
+
+ protected void initializeHibernateNamedNativeQueries() {
+ for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.hibernateNamedNativeQueries.add(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
stream.next()));
+ }
+ }
+
+ protected HibernateNamedNativeQuery
buildHibernateNamedNativeQuery(HibernateNamedNativeQueryAnnotation namedQueryResource) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
+ hibernateNamedNativeQuery.initialize(namedQueryResource);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void updateHibernateNamedNativeQueries() {
+ ListIterator<HibernateNamedNativeQuery> queries = hibernateNamedNativeQueries();
+ ListIterator<NestableAnnotation> resourceNamedNativeQueries =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+
+ while (queries.hasNext()) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery = queries.next();
+ if (resourceNamedNativeQueries.hasNext()) {
+ hibernateNamedNativeQuery.update((HibernateNamedNativeQueryAnnotation)
resourceNamedNativeQueries.next());
+ }
+ else {
+ removeHibernateNamedNativeQuery_(hibernateNamedNativeQuery);
+ }
+ }
+
+ while (resourceNamedNativeQueries.hasNext()) {
+ Object test = resourceNamedNativeQueries.next();
+ if (!(test instanceof HibernateNamedNativeQueryAnnotation)){
+ System.out.println("error!");//$NON-NLS-1$
+ }
+ addHibernateNamedNativeQuery(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
test));
+ }
+ }
+
+ public HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
+ this.hibernateNamedNativeQueries.add(index, hibernateNamedNativeQuery);
+ HibernateNamedNativeQueryAnnotation hibernateNamedNativeQueryAnnotation =
(HibernateNamedNativeQueryAnnotation) this.javaResourcePersistentType
+ .addSupportingAnnotation(index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ hibernateNamedNativeQuery.initialize(hibernateNamedNativeQueryAnnotation);
+ fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, hibernateNamedNativeQuery);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void addHibernateNamedNativeQuery(int index, HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ addItemToList(index, hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ protected void addHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ this.addHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size(),
hibernateNamedNativeQuery);
+ }
+
+ public void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ removeHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.indexOf(hibernateNamedNativeQuery));
+ }
+
+ public void removeHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery removedHibernateNamedNativeQuery =
this.hibernateNamedNativeQueries.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index,
HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index,
removedHibernateNamedNativeQuery);
+ }
+
+ protected void removeHibernateNamedNativeQuery_(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ removeItemFromList(hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ public void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
// ************************* validation ***********************
@Override
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.context.java.JavaNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateNamedNativeQuery extends JavaNamedNativeQuery,
+ HibernateQuery {
+
+ String HIBERNATE_NAMED_NATIVE_QUERY="hibernateNamedNativeQuery";
//$NON-NLS-1$
+
+ //************************ callable *********************************
+ boolean isCallable();
+ Boolean getSpecifiedCallable();
+ void setSpecifiedCallable(Boolean value);
+ String SPECIFIED_CALLABLE_PROPERTY = "specifiedCallable"; //$NON-NLS-1$
+
+ boolean isDefaultCallable();
+ boolean DEFAULT_CALLABLE = false;
+ String DEFAULT_CALLABLE_PROPERTY = "defaultCallable"; //$NON-NLS-1$
+
+
+ void initialize(HibernateNamedNativeQueryAnnotation resourceNamedQuery);
+
+ void update(HibernateNamedNativeQueryAnnotation resourceNamedQuery);
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -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.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$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * 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.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueryImpl extends GenericJavaNamedNativeQuery
+ implements HibernateNamedNativeQuery {
+
+ private FlushModeType specifiedFlushMode;
+
+ private CacheModeType specifiedCacheMode;
+
+ private Boolean specifiedCacheable;
+
+ private String specifiedCacheRegion;
+
+ private Integer specifiedFetchSize;
+
+ private Integer specifiedTimeout;
+
+ private String specifiedComment;
+
+ private Boolean specifiedReadOnly;
+
+ private Boolean specifiedCallable;
+
+ /**
+ * @param parent
+ */
+ public HibernateNamedNativeQueryImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
+ this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
+ this.specifiedCacheable = resourceQuery.isCacheable();
+ this.specifiedCacheRegion = resourceQuery.getCacheRegion();
+ this.specifiedFetchSize = resourceQuery.getFetchSize();
+ this.specifiedTimeout = resourceQuery.getTimeout();
+ this.specifiedComment = resourceQuery.getComment();
+ this.specifiedReadOnly = resourceQuery.isReadOnly();
+ this.specifiedCallable = resourceQuery.isCallable();
+ super.initialize(resourceQuery);
+ }
+
+ public void update(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ this.setFlushMode_(resourceQuery.getFlushMode());
+ this.setCacheMode_ (resourceQuery.getCacheMode());
+ this.setSpecifiedCacheable_(resourceQuery.isCacheable());
+ this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
+ this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
+ this.setSpecifiedTimeout_(resourceQuery.getTimeout());
+ this.setSpecifiedComment_(resourceQuery.getComment());
+ this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
+ this.setSpecifiedCallable_(resourceQuery.isCallable());
+ super.update(resourceQuery);
+ }
+
+ private CacheModeType getResourceCacheMode(HibernateNamedNativeQueryAnnotation
resourceQuery) {
+ return CacheModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ private FlushModeType getResourceFlushMode(HibernateNamedNativeQueryAnnotation
resourceQuery) {
+ return FlushModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ @Override
+ protected HibernateNamedNativeQueryAnnotation getResourceQuery() {
+ return (HibernateNamedNativeQueryAnnotation) super.getResourceQuery();
+ }
+
+ // ****** flushMode
+ public FlushModeType getFlushMode() {
+ return getSpecifiedFlushMode() == null ? getDefaultFlushMode() :
getSpecifiedFlushMode();
+ }
+
+ public FlushModeType getSpecifiedFlushMode() {
+ return specifiedFlushMode;
+ }
+
+ public FlushModeType getDefaultFlushMode() {
+ return HibernateNamedNativeQuery.DEFAULT_FLUSH_MODE_TYPE;
+ }
+
+ public void setSpecifiedFlushMode(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ getResourceQuery().setFlushMode(flushMode);
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+
+ protected void setFlushMode_(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+ // ****** cacheMode
+ public CacheModeType getCacheMode() {
+ return getSpecifiedCacheMode() == null ? getDefaultCacheMode() :
getSpecifiedCacheMode();
+ }
+
+ public CacheModeType getDefaultCacheMode() {
+ return HibernateNamedNativeQuery.DEFAULT_CACHE_MODE_TYPE;
+ }
+
+ public CacheModeType getSpecifiedCacheMode() {
+ return specifiedCacheMode;
+ }
+
+ public void setSpecifiedCacheMode(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ getResourceQuery().setCacheMode(cacheMode);
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+
+ public void setCacheMode_(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+ //************************ cacheable *********************************
+ public boolean isCacheable(){
+ return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
+ : this.getSpecifiedCacheable().booleanValue();
+ }
+
+ public Boolean getSpecifiedCacheable(){
+ return this.specifiedCacheable;
+ }
+
+ public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ this.getResourceQuery().setCacheable(newSpecifiedCacheable);
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
+
+ }
+
+ public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
+ }
+
+ public boolean isDefaultCacheable() {
+ return HibernateNamedNativeQuery.DEFAULT_CACHEABLE;
+ }
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
+ : getSpecifiedCacheRegion());
+ }
+ public String getSpecifiedCacheRegion(){
+ return this.specifiedCacheRegion;
+ }
+
+ public void setSpecifiedCacheRegion(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ this.getResourceQuery().setCacheRegion(cacheRegion);
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
+ }
+
+ public void setSpecifiedCacheRegion_(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
+ }
+
+ public String getDefaultCacheRegion(){
+ return HibernateNamedNativeQuery.DEFAULT_CACHE_REGION;
+ }
+ //************************ fetchSize *********************************
+ public int getFetchSize(){
+ return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
+ : getSpecifiedFetchSize().intValue());
+ }
+
+ public Integer getSpecifiedFetchSize(){
+ return this.specifiedFetchSize;
+ }
+
+ public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = newSpecifiedFetchSize;
+ this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize,
newSpecifiedFetchSize);
+ }
+
+ public void setSpecifiedFetchSize_(Integer fetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = fetchSize;
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
+ }
+
+ public int getDefaultFetchSize(){
+ return HibernateNamedNativeQuery.DEFAULT_FETCH_SIZE;
+ }
+ //************************ timeout *********************************
+ public int getTimeout(){
+ return (getSpecifiedTimeout() == null ? getDefaultTimeout()
+ : getSpecifiedTimeout().intValue());
+ }
+
+ public Integer getSpecifiedTimeout(){
+ return this.specifiedTimeout;
+ }
+
+ public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = newSpecifiedTimeout;
+ this.getResourceQuery().setTimeout(newSpecifiedTimeout);
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout,
newSpecifiedTimeout);
+ }
+
+ public void setSpecifiedTimeout_(Integer timeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = timeout;
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
+ }
+
+ public int getDefaultTimeout(){
+ return HibernateNamedNativeQuery.DEFAULT_TIMEOUT;
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return (getSpecifiedComment() == null ? getDefaultComment()
+ : getSpecifiedComment());
+ }
+ public String getSpecifiedComment(){
+ return this.specifiedComment;
+ }
+
+ public void setSpecifiedComment(String newSpecifiedComment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = newSpecifiedComment;
+ this.getResourceQuery().setComment(newSpecifiedComment);
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment,
newSpecifiedComment);
+ }
+
+ public void setSpecifiedComment_(String comment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = comment;
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
+ }
+
+ public String getDefaultComment(){
+ return HibernateNamedNativeQuery.DEFAULT_COMMENT;
+ }
+
+ //************************ readOnly *********************************
+ public boolean isReadOnly(){
+ return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
+ : getSpecifiedReadOnly().booleanValue());
+ }
+
+ public Boolean getSpecifiedReadOnly(){
+ return this.specifiedReadOnly;
+ }
+
+ public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = newSpecifiedReadOnly;
+ this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly,
newSpecifiedReadOnly);
+ }
+
+ public void setSpecifiedReadOnly_(Boolean readOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = readOnly;
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
+ }
+
+ public boolean isDefaultReadOnly(){
+ return HibernateNamedNativeQuery.DEFAULT_READ_ONLY;
+ }
+
+ //************************ callable *********************************
+ public boolean isCallable(){
+ return (getSpecifiedCallable() == null ? isDefaultCallable()
+ : getSpecifiedCallable().booleanValue());
+ }
+
+ public Boolean getSpecifiedCallable(){
+ return this.specifiedCallable;
+ }
+
+ public void setSpecifiedCallable(Boolean newSpecifiedCallable){
+ Boolean oldSpecifiedCallable = this.specifiedCallable;
+ this.specifiedCallable = newSpecifiedCallable;
+ this.getResourceQuery().setCallable(newSpecifiedCallable);
+ firePropertyChanged(SPECIFIED_CALLABLE_PROPERTY, oldSpecifiedCallable,
newSpecifiedCallable);
+ }
+
+ public void setSpecifiedCallable_(Boolean callable){
+ Boolean oldSpecifiedCallable = this.specifiedCallable;
+ this.specifiedCallable = callable;
+ firePropertyChanged(SPECIFIED_CALLABLE_PROPERTY, oldSpecifiedCallable, callable);
+ }
+
+ public boolean isDefaultCallable(){
+ return HibernateNamedNativeQuery.DEFAULT_CALLABLE;
+ }
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.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/context/java/HibernateNamedQuery.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -11,98 +11,16 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaNamedQuery;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
*
*/
-public interface HibernateNamedQuery extends JavaNamedQuery {
+public interface HibernateNamedQuery extends JavaNamedQuery, HibernateQuery {
String HIBERNATE_NAMED_QUERY="hibernateNamedQuery"; //$NON-NLS-1$
- // **************** flushMode ***************************************************
-
- FlushModeType getFlushMode();
- FlushModeType getSpecifiedFlushMode();
- String SPECIFIED_FLUSH_MODE_PROPERTY = "specifiedFlushMode"; //$NON-NLS-1$
- FlushModeType getDefaultFlushMode();
- String DEFAULT_FLUSH_MODE_PROPERTY = "defaultFlushMode"; //$NON-NLS-1$
- FlushModeType DEFAULT_FLUSH_MODE_TYPE = FlushModeType.AUTO;
-
- void setSpecifiedFlushMode(FlushModeType flushMode);
-
- //************************ cacheMode *********************************
-
- CacheModeType getCacheMode();
- CacheModeType getSpecifiedCacheMode();
- String SPECIFIED_CACHE_MODE_PROPERTY = "specifiedCacheMode"; //$NON-NLS-1$
- CacheModeType getDefaultCacheMode();
- String DEFAULT_CACHE_MODE_PROPERTY = "defaultCacheMode"; //$NON-NLS-1$
- CacheModeType DEFAULT_CACHE_MODE_TYPE = CacheModeType.NORMAL;
-
- void setSpecifiedCacheMode(CacheModeType cacheMode);
-
- //************************ cacheable *********************************
- boolean isCacheable();
- Boolean getSpecifiedCacheable();
- void setSpecifiedCacheable(Boolean value);
- String SPECIFIED_CACHEABLE_PROPERTY = "specifiedCacheable"; //$NON-NLS-1$
-
- boolean isDefaultCacheable();
- boolean DEFAULT_CACHEABLE = false;
- String DEFAULT_CACHEABLE_PROPERTY = "defaultCacheable"; //$NON-NLS-1$
- //************************ cacheRegion *********************************
- String getCacheRegion();
- String getSpecifiedCacheRegion();
- void setSpecifiedCacheRegion(String value);
- String SPECIFIED_CACHE_REGION_PROPERTY = "specifiedCacheRegion";
//$NON-NLS-1$
-
- String getDefaultCacheRegion();
- String DEFAULT_CACHE_REGION = ""; //$NON-NLS-1$
- String DEFAULT_CACHE_REGION_PROPERTY = "defaultCacheRegion"; //$NON-NLS-1$
-
- //************************ fetchSize *********************************
- int getFetchSize();
-
- Integer getSpecifiedFetchSize();
- void setSpecifiedFetchSize(Integer value);
- String SPECIFIED_FETCH_SIZE_PROPERTY = "specifiedFetchSize"; //$NON-NLS-1$
-
- int getDefaultFetchSize();
- int DEFAULT_FETCH_SIZE = -1;
- String DEFAULT_FETCH_SIZE_PROPERTY = "defaultFetchSize"; //$NON-NLS-1$
-
- //************************ timeout *********************************
- int getTimeout();
-
- Integer getSpecifiedTimeout();
- void setSpecifiedTimeout(Integer value);
- String SPECIFIED_TIMEOUT_PROPERTY = "specifiedTimeout"; //$NON-NLS-1$
-
- int getDefaultTimeout();
- int DEFAULT_TIMEOUT = -1;
- String DEFAULT_TIMEOUT_PROPERTY = "defaultTimeout"; //$NON-NLS-1$
-
- //************************ comment *********************************
- String getComment();
- String getSpecifiedComment();
- void setSpecifiedComment(String value);
- String SPECIFIED_COMMENT_PROPERTY = "specifiedComment"; //$NON-NLS-1$
-
- String getDefaultComment();
- String DEFAULT_COMMENT = ""; //$NON-NLS-1$
- String DEFAULT_COMMENT_PROPERTY = "defaultComment"; //$NON-NLS-1$
-
- //************************ readOnly *********************************
- boolean isReadOnly();
- Boolean getSpecifiedReadOnly();
- void setSpecifiedReadOnly(Boolean value);
- String SPECIFIED_READ_ONLY_PROPERTY = "specifiedReadOnly"; //$NON-NLS-1$
-
- boolean isDefaultReadOnly();
- boolean DEFAULT_READ_ONLY = false;
- String DEFAULT_READ_ONLY_PROPERTY = "defaultReadOnly"; //$NON-NLS-1$
-
void initialize(HibernateNamedQueryAnnotation resourceNamedQuery);
void update(HibernateNamedQueryAnnotation resourceNamedQuery);
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -1,98 +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.resource.java.NestableNamedQueryAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation {
-
- //replace with Hibernate annotation
- String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
-
- //************************ 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/HibernateNamedQueryAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -1,53 +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.IAnnotation;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateNamedQueryAnnotationDefinition implements AnnotationDefinition {
-
- // singleton
- private static final AnnotationDefinition INSTANCE = new
HibernateNamedQueryAnnotationDefinition();
-
- /**
- * Return the singleton.
- */
- public static AnnotationDefinition instance() {
- return INSTANCE;
- }
-
- public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
- return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, member);
- }
-
- public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
- throw new UnsupportedOperationException();
- }
-
- public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation
jdtAnnotation) {
- //TODO return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
- throw new UnsupportedOperationException();
- }
-
- public String getAnnotationName() {
- return Hibernate.NAMED_QUERY;
- }
-}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java
(from rev 16518,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedQueryImpl extends GenericJavaNamedQuery
+ implements HibernateNamedQuery {
+
+ private FlushModeType specifiedFlushMode;
+
+ private CacheModeType specifiedCacheMode;
+
+ private Boolean specifiedCacheable;
+
+ private String specifiedCacheRegion;
+
+ private Integer specifiedFetchSize;
+
+ private Integer specifiedTimeout;
+
+ private String specifiedComment;
+
+ private Boolean specifiedReadOnly;
+
+ /**
+ * @param parent
+ */
+ public HibernateNamedQueryImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(HibernateNamedQueryAnnotation resourceQuery) {
+ this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
+ this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
+ this.specifiedCacheable = resourceQuery.isCacheable();
+ this.specifiedCacheRegion = resourceQuery.getCacheRegion();
+ this.specifiedFetchSize = resourceQuery.getFetchSize();
+ this.specifiedTimeout = resourceQuery.getTimeout();
+ this.specifiedComment = resourceQuery.getComment();
+ this.specifiedReadOnly = resourceQuery.isReadOnly();
+ super.initialize(resourceQuery);
+ }
+
+ public void update(HibernateNamedQueryAnnotation resourceQuery) {
+ this.setFlushMode_(resourceQuery.getFlushMode());
+ this.setCacheMode_ (resourceQuery.getCacheMode());
+ this.setSpecifiedCacheable_(resourceQuery.isCacheable());
+ this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
+ this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
+ this.setSpecifiedTimeout_(resourceQuery.getTimeout());
+ this.setSpecifiedComment_(resourceQuery.getComment());
+ this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
+ super.update(resourceQuery);
+ }
+
+ private CacheModeType getResourceCacheMode(HibernateNamedQueryAnnotation resourceQuery)
{
+ return CacheModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ private FlushModeType getResourceFlushMode(HibernateNamedQueryAnnotation resourceQuery)
{
+ return FlushModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ @Override
+ protected HibernateNamedQueryAnnotation getResourceQuery() {
+ return (HibernateNamedQueryAnnotation) super.getResourceQuery();
+ }
+
+ // ****** flushMode
+ public FlushModeType getFlushMode() {
+ return getSpecifiedFlushMode() == null ? getDefaultFlushMode() :
getSpecifiedFlushMode();
+ }
+
+ public FlushModeType getSpecifiedFlushMode() {
+ return specifiedFlushMode;
+ }
+
+ public FlushModeType getDefaultFlushMode() {
+ return HibernateNamedQuery.DEFAULT_FLUSH_MODE_TYPE;
+ }
+
+ public void setSpecifiedFlushMode(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ getResourceQuery().setFlushMode(flushMode);
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+
+ protected void setFlushMode_(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+ // ****** cacheMode
+ public CacheModeType getCacheMode() {
+ return getSpecifiedCacheMode() == null ? getDefaultCacheMode() :
getSpecifiedCacheMode();
+ }
+
+ public CacheModeType getDefaultCacheMode() {
+ return HibernateNamedQuery.DEFAULT_CACHE_MODE_TYPE;
+ }
+
+ public CacheModeType getSpecifiedCacheMode() {
+ return specifiedCacheMode;
+ }
+
+ public void setSpecifiedCacheMode(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ getResourceQuery().setCacheMode(cacheMode);
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+
+ public void setCacheMode_(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+ //************************ cacheable *********************************
+ public boolean isCacheable(){
+ return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
+ : this.getSpecifiedCacheable().booleanValue();
+ }
+
+ public Boolean getSpecifiedCacheable(){
+ return this.specifiedCacheable;
+ }
+
+ public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ this.getResourceQuery().setCacheable(newSpecifiedCacheable);
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
+
+ }
+
+ public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable,
newSpecifiedCacheable);
+ }
+
+ public boolean isDefaultCacheable() {
+ return HibernateNamedQuery.DEFAULT_CACHEABLE;
+ }
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
+ : getSpecifiedCacheRegion());
+ }
+ public String getSpecifiedCacheRegion(){
+ return this.specifiedCacheRegion;
+ }
+
+ public void setSpecifiedCacheRegion(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ this.getResourceQuery().setCacheRegion(cacheRegion);
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
+ }
+
+ public void setSpecifiedCacheRegion_(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion,
cacheRegion);
+ }
+
+ public String getDefaultCacheRegion(){
+ return HibernateNamedQuery.DEFAULT_CACHE_REGION;
+ }
+ //************************ fetchSize *********************************
+ public int getFetchSize(){
+ return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
+ : getSpecifiedFetchSize().intValue());
+ }
+
+ public Integer getSpecifiedFetchSize(){
+ return this.specifiedFetchSize;
+ }
+
+ public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = newSpecifiedFetchSize;
+ this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize,
newSpecifiedFetchSize);
+ }
+
+ public void setSpecifiedFetchSize_(Integer fetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = fetchSize;
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
+ }
+
+ public int getDefaultFetchSize(){
+ return HibernateNamedQuery.DEFAULT_FETCH_SIZE;
+ }
+ //************************ timeout *********************************
+ public int getTimeout(){
+ return (getSpecifiedTimeout() == null ? getDefaultTimeout()
+ : getSpecifiedTimeout().intValue());
+ }
+
+ public Integer getSpecifiedTimeout(){
+ return this.specifiedTimeout;
+ }
+
+ public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = newSpecifiedTimeout;
+ this.getResourceQuery().setTimeout(newSpecifiedTimeout);
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout,
newSpecifiedTimeout);
+ }
+
+ public void setSpecifiedTimeout_(Integer timeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = timeout;
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
+ }
+
+ public int getDefaultTimeout(){
+ return HibernateNamedQuery.DEFAULT_TIMEOUT;
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return (getSpecifiedComment() == null ? getDefaultComment()
+ : getSpecifiedComment());
+ }
+ public String getSpecifiedComment(){
+ return this.specifiedComment;
+ }
+
+ public void setSpecifiedComment(String newSpecifiedComment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = newSpecifiedComment;
+ this.getResourceQuery().setComment(newSpecifiedComment);
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment,
newSpecifiedComment);
+ }
+
+ public void setSpecifiedComment_(String comment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = comment;
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
+ }
+
+ public String getDefaultComment(){
+ return HibernateNamedQuery.DEFAULT_COMMENT;
+ }
+
+ //************************ readOnly *********************************
+ public boolean isReadOnly(){
+ return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
+ : getSpecifiedReadOnly().booleanValue());
+ }
+
+ public Boolean getSpecifiedReadOnly(){
+ return this.specifiedReadOnly;
+ }
+
+ public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = newSpecifiedReadOnly;
+ this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly,
newSpecifiedReadOnly);
+ }
+
+ public void setSpecifiedReadOnly_(Boolean readOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = readOnly;
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
+ }
+
+ public boolean isDefaultReadOnly(){
+ return HibernateNamedQuery.DEFAULT_READ_ONLY;
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.context.Query;
+import org.eclipse.jpt.utility.model.Model;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateQuery extends Query, Model {
+
+ // **************** flushMode ***************************************************
+
+ FlushModeType getFlushMode();
+ FlushModeType getSpecifiedFlushMode();
+ String SPECIFIED_FLUSH_MODE_PROPERTY = "specifiedFlushMode"; //$NON-NLS-1$
+ FlushModeType getDefaultFlushMode();
+ String DEFAULT_FLUSH_MODE_PROPERTY = "defaultFlushMode"; //$NON-NLS-1$
+ FlushModeType DEFAULT_FLUSH_MODE_TYPE = FlushModeType.AUTO;
+
+ void setSpecifiedFlushMode(FlushModeType flushMode);
+
+ //************************ cacheMode *********************************
+
+ CacheModeType getCacheMode();
+ CacheModeType getSpecifiedCacheMode();
+ String SPECIFIED_CACHE_MODE_PROPERTY = "specifiedCacheMode"; //$NON-NLS-1$
+ CacheModeType getDefaultCacheMode();
+ String DEFAULT_CACHE_MODE_PROPERTY = "defaultCacheMode"; //$NON-NLS-1$
+ CacheModeType DEFAULT_CACHE_MODE_TYPE = CacheModeType.NORMAL;
+
+ void setSpecifiedCacheMode(CacheModeType cacheMode);
+
+ //************************ cacheable *********************************
+ boolean isCacheable();
+ Boolean getSpecifiedCacheable();
+ void setSpecifiedCacheable(Boolean value);
+ String SPECIFIED_CACHEABLE_PROPERTY = "specifiedCacheable"; //$NON-NLS-1$
+
+ boolean isDefaultCacheable();
+ boolean DEFAULT_CACHEABLE = false;
+ String DEFAULT_CACHEABLE_PROPERTY = "defaultCacheable"; //$NON-NLS-1$
+
+ //************************ cacheRegion *********************************
+ String getCacheRegion();
+ String getSpecifiedCacheRegion();
+ void setSpecifiedCacheRegion(String value);
+ String SPECIFIED_CACHE_REGION_PROPERTY = "specifiedCacheRegion";
//$NON-NLS-1$
+
+ String getDefaultCacheRegion();
+ String DEFAULT_CACHE_REGION = ""; //$NON-NLS-1$
+ String DEFAULT_CACHE_REGION_PROPERTY = "defaultCacheRegion"; //$NON-NLS-1$
+
+ //************************ fetchSize *********************************
+ int getFetchSize();
+
+ Integer getSpecifiedFetchSize();
+ void setSpecifiedFetchSize(Integer value);
+ String SPECIFIED_FETCH_SIZE_PROPERTY = "specifiedFetchSize"; //$NON-NLS-1$
+
+ int getDefaultFetchSize();
+ int DEFAULT_FETCH_SIZE = -1;
+ String DEFAULT_FETCH_SIZE_PROPERTY = "defaultFetchSize"; //$NON-NLS-1$
+
+ //************************ timeout *********************************
+ int getTimeout();
+
+ Integer getSpecifiedTimeout();
+ void setSpecifiedTimeout(Integer value);
+ String SPECIFIED_TIMEOUT_PROPERTY = "specifiedTimeout"; //$NON-NLS-1$
+
+ int getDefaultTimeout();
+ int DEFAULT_TIMEOUT = -1;
+ String DEFAULT_TIMEOUT_PROPERTY = "defaultTimeout"; //$NON-NLS-1$
+
+ //************************ comment *********************************
+ String getComment();
+ String getSpecifiedComment();
+ void setSpecifiedComment(String value);
+ String SPECIFIED_COMMENT_PROPERTY = "specifiedComment"; //$NON-NLS-1$
+
+ String getDefaultComment();
+ String DEFAULT_COMMENT = ""; //$NON-NLS-1$
+ String DEFAULT_COMMENT_PROPERTY = "defaultComment"; //$NON-NLS-1$
+
+ //************************ readOnly *********************************
+ boolean isReadOnly();
+ Boolean getSpecifiedReadOnly();
+ void setSpecifiedReadOnly(Boolean value);
+ String SPECIFIED_READ_ONLY_PROPERTY = "specifiedReadOnly"; //$NON-NLS-1$
+
+ boolean isDefaultReadOnly();
+ boolean DEFAULT_READ_ONLY = false;
+ String DEFAULT_READ_ONLY_PROPERTY = "defaultReadOnly"; //$NON-NLS-1$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.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/context/java/HibernateQueryContainer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -21,6 +21,8 @@
public interface HibernateQueryContainer extends QueryContainer {
String HIBERNATE_NAMED_QUERIES_LIST = "hibernateNamedQueries"; //$NON-NLS-1$
+
+ String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedNativeQueries";
//$NON-NLS-1$
// ********** named queries **********
/**
@@ -53,5 +55,39 @@
* Move the named query from the source index to the target index.
*/
void moveHibernateNamedQuery(int targetIndex, int sourceIndex);
+
+ // ********** named native queries **********
+ /**
+ * Return a list iterator of the specified named native queries.
+ * This will not be null.
+ */
+ <T extends HibernateNamedNativeQuery> ListIterator<T>
hibernateNamedNativeQueries();
+
+ /**
+ * Return the number of named native queries.
+ */
+ int hibernateNamedNativeQueriesSize();
+
+ /**
+ * Add a named native query to the entity return the object representing it.
+ */
+ HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at the index from the entity.
+ */
+ void removeHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at from the entity.
+ */
+ void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery namedNativeQuery);
+
+ /**
+ * Move the named native query from the source index to the target index.
+ */
+ void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex);
+
+
}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,613 @@
+/*******************************************************************************
+ * 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);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.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/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-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -35,6 +35,7 @@
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
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateNamedNativeQueriesAnnotation extends
+ ContainerAnnotation<HibernateNamedNativeQueryAnnotation> {
+
+ String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERIES;
+
+ String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedNativeQueries";
//$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/HibernateNamedNativeQueriesAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueriesAnnotationDefinition implements
AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new
HibernateNamedNativeQueriesAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedNativeQueriesAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new HibernateSourceNamedNativeQueriesAnnotation(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation
jdtAnnotation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.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
+ *
+ */
+public class HibernateNamedNativeQueryAnnotationDefinition implements
AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new
HibernateNamedNativeQueryAnnotationDefinition();
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedNativeQueryAnnotationDefinition() {
+ super();
+ }
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent,
member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation
jdtAnnotation) {
+ //TODO return new HibernateBinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return Hibernate.NAMED_NATIVE_QUERY;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.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/HibernateNamedQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -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.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
(from rev 16518,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.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
+ *
+ * Corresponds to the Hibernate annotation
+ * org.hibernate.annotations.NamedQuery
+ */
+public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation,
+HibernateQueryAnnotation {
+ //replace with Hibernate annotation
+ String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
(from rev 16282,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+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
+ *
+ */
+public class HibernateNamedQueryAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new
HibernateNamedQueryAnnotationDefinition();
+
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedQueryAnnotationDefinition() {
+ super();
+ }
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation
jdtAnnotation) {
+ //TODO return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return Hibernate.NAMED_QUERY;
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.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.JavaResourceNode;
+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;
+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
+ *
+ */
+public class HibernateSourceNamedNativeQueriesAnnotation extends
SourceAnnotation<Member> implements
+ HibernateNamedNativeQueriesAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final Vector<HibernateNamedNativeQueryAnnotation>
hibernateNamedNativeQueries = new Vector<HibernateNamedNativeQueryAnnotation>();
+
+
+ public HibernateSourceNamedNativeQueriesAnnotation(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.hibernateNamedNativeQueries);
+ }
+
+ // ********** 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.NAMED_NATIVE_QUERIES__VALUE;
+ }
+
+ public String getNestableAnnotationName() {
+ return HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<HibernateNamedNativeQueryAnnotation> nestedAnnotations() {
+ return new
CloneListIterator<HibernateNamedNativeQueryAnnotation>(this.hibernateNamedNativeQueries);
+ }
+
+ public int nestedAnnotationsSize() {
+ return this.hibernateNamedNativeQueries.size();
+ }
+
+ public HibernateNamedNativeQueryAnnotation addNestedAnnotationInternal() {
+ HibernateNamedNativeQueryAnnotation namedQuery =
this.buildHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size());
+ this.hibernateNamedNativeQueries.add(namedQuery);
+ return namedQuery;
+ }
+
+ private HibernateNamedNativeQueryAnnotation buildHibernateNamedNativeQuery(int index) {
+ return
HibernateSourceNamedNativeQueryAnnotation.createNestedHibernateNamedNativeQuery(this,
member, index, this.daa);
+ }
+
+ public void nestedAnnotationAdded(int index, HibernateNamedNativeQueryAnnotation
nestedAnnotation) {
+ this.fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
+ }
+
+ public HibernateNamedNativeQueryAnnotation moveNestedAnnotationInternal(int targetIndex,
int sourceIndex) {
+ return CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex,
sourceIndex).get(targetIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ public HibernateNamedNativeQueryAnnotation removeNestedAnnotationInternal(int index) {
+ return this.hibernateNamedNativeQueries.remove(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, HibernateNamedNativeQueryAnnotation
nestedAnnotation) {
+ this.fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
+ }
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.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/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-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -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.HibernateNamedQueryAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
@@ -115,5 +114,4 @@
this.fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, nestedAnnotation);
}
-
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -14,8 +14,10 @@
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.java.details.JavaEntityComposite;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateQueriesComposite;
@@ -35,6 +37,7 @@
super(subjectHolder, parent, widgetFactory);
}
+ @SuppressWarnings("unchecked")
@Override
protected void initializeQueriesPane(Composite container) {
container = addCollapsableSection(
@@ -42,7 +45,7 @@
JptUiMappingsMessages.EntityComposite_queries
);
- new HibernateQueriesComposite(this, container);
+ new HibernateQueriesComposite((Pane<? extends HibernateQueryContainer>) this,
container);
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
/**
@@ -136,7 +137,7 @@
queryTypes.add(Query.NAMED_QUERY);
queryTypes.add(Query.NAMED_NATIVE_QUERY);
queryTypes.add(HibernateNamedQuery.HIBERNATE_NAMED_QUERY);
-
+ queryTypes.add(HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY);
return new StaticListValueModel<String>(queryTypes);
}
@@ -152,6 +153,9 @@
if (value == HibernateNamedQuery.HIBERNATE_NAMED_QUERY) {
return HibernateUIMappingMessages.HibernateAddQueryDialog_hibernateNamedQuery;
}
+ if (value == HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY) {
+ return
HibernateUIMappingMessages.HibernateAddQueryDialog_hibernateNamedNativeQuery;
+ }
return value;
}
};
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueryPropertyComposite extends
+ HibernateQueryPropertyComposite<HibernateNamedNativeQuery> {
+
+ private ClassChooserPane<HibernateNamedNativeQuery> resultClassChooserPane;
+
+ /**
+ * Creates a new <code>HibernateNamedNativeQueryPropertyComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param subjectHolder The holder of this pane's subject
+ * @param parent The parent container
+ */
+ public HibernateNamedNativeQueryPropertyComposite(Pane<?> parentPane,
+ PropertyValueModel<? extends
HibernateNamedNativeQuery> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ private ClassChooserPane<HibernateNamedNativeQuery> addClassChooser(Composite
container) {
+
+ return new ClassChooserPane<HibernateNamedNativeQuery>(this, container) {
+
+ @Override
+ protected WritablePropertyValueModel<String> buildTextHolder() {
+ return new PropertyAspectAdapter<HibernateNamedNativeQuery,
String>(getSubjectHolder(), HibernateNamedNativeQuery.RESULT_CLASS_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getResultClass();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ this.subject.setResultClass(value);
+ }
+ };
+ }
+
+ @Override
+ protected String getClassName() {
+ return getSubject().getResultClass();
+ }
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.NamedNativeQueryPropertyComposite_resultClass;
+ }
+
+ @Override
+ protected JpaProject getJpaProject() {
+ return getSubject().getJpaProject();
+ }
+
+ @Override
+ protected void setClassName(String className) {
+ getSubject().setResultClass(className);
+ }
+
+ @Override
+ protected char getEnclosingTypeSeparator() {
+ return getSubject().getResultClassEnclosingTypeSeparator();
+ }
+ };
+ }
+
+
+ @Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+ this.resultClassChooserPane.enableWidgets(enabled);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ super.initializeLayout(container);
+
+ // Result class chooser
+ this.resultClassChooserPane = addClassChooser(container);
+
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.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.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -10,33 +10,16 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
-import java.util.Collection;
-
-import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateNamedQueryPropertyComposite extends Pane<HibernateNamedQuery>
{
+public class HibernateNamedQueryPropertyComposite extends
HibernateQueryPropertyComposite<HibernateNamedQuery> {
/**
* Creates a new <code>HibernateNamedQueryPropertyComposite</code>.
@@ -52,439 +35,4 @@
super(parentPane, subjectHolder, parent);
}
- @Override
- protected void initializeLayout(Composite container) {
-
- addLabeledText(
- container,
- JptUiMappingsMessages.NamedQueryComposite_nameTextLabel,
- buildNameTextHolder());
-
- // Query text area
- addLabeledMultiLineText(
- container,
- JptUiMappingsMessages.NamedQueryPropertyComposite_query,
- buildQueryHolder(),
- 4,
- null
- );
-
- // ReadOnly tri-state check box
- addTriStateCheckBoxWithDefault(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly,
- buildReadOnlyHolder(),
- buildReadOnlyStringHolder(),
- null//TODO help
- );
-
- //Flush Mode combobox
- addLabeledComposite(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_flushMode,
- addFlushModeTypeCombo(container),
- null//TODO help
- );
-
- // Cacheable tri-state check box
- addTriStateCheckBoxWithDefault(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable,
- buildCacheableHolder(),
- buildCacheableStringHolder(),
- null//TODO help
- );
-
- //Cache Mode combobox
- addLabeledComposite(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheMode,
- addCacheModeTypeCombo(container),
- null//TODO help
- );
-
- addLabeledText(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheRegion,
- buildCacheRegionTextHolder());
-
- // Fetch size widgets
- Spinner fetchSizeSpinner = addLabeledSpinner(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_fetchSize,
- buildFetchSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultFetchSizeLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, fetchSizeSpinner);
-
- // Timeout size widgets
- Spinner timeoutSpinner = addLabeledSpinner(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_timeout,
- buildTimeoutHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultFetchSizeLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, timeoutSpinner);
-
- }
-
- private Control addDefaultFetchSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultFetchSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultFetchSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer,
String>(buildDefaultFetchSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultFetchSize() :
- HibernateNamedQuery.DEFAULT_FETCH_SIZE;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultFetchSizeHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery,
Integer>(getSubjectHolder(), HibernateNamedQuery.DEFAULT_FETCH_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultFetchSize());
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- protected WritablePropertyValueModel<String> buildNameTextHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(
- getSubjectHolder(), HibernateNamedQuery.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildQueryHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(getSubjectHolder(),
HibernateNamedQuery.QUERY_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getQuery();
- }
-
- @Override
- protected void setValue_(String value) {
- this.subject.setQuery(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildCacheableHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Boolean>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_CACHEABLE_PROPERTY,
- HibernateNamedQuery.SPECIFIED_CACHEABLE_PROPERTY)
- {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSpecifiedCacheable();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setSpecifiedCacheable(value);
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildCacheableStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean,
String>(buildCacheableHolder()) {
-
- @Override
- protected String transform(Boolean value) {
-
- if ((getSubject() != null) && (value == null)) {
- boolean defaultValue = getSubject().isDefaultCacheable();
-
- String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
- JptUiMappingsMessages.Boolean_False;
-
- return NLS.bind(
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheableWithDefault,
- defaultStringValue
- );
- }
-
- return HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable;
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildReadOnlyHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Boolean>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_READ_ONLY_PROPERTY,
- HibernateNamedQuery.SPECIFIED_READ_ONLY_PROPERTY)
- {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSpecifiedReadOnly();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setSpecifiedReadOnly(value);
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildReadOnlyStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean,
String>(buildReadOnlyHolder()) {
-
- @Override
- protected String transform(Boolean value) {
-
- if ((getSubject() != null) && (value == null)) {
- boolean defaultValue = getSubject().isDefaultReadOnly();
-
- String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
- JptUiMappingsMessages.Boolean_False;
-
- return NLS.bind(
- HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnlyWithDefault,
- defaultStringValue
- );
- }
-
- return HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly;
- }
- };
- }
-
- private EnumFormComboViewer<HibernateNamedQuery, FlushModeType>
addFlushModeTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<HibernateNamedQuery, FlushModeType>(this,
container) {
-
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(HibernateNamedQuery.DEFAULT_FLUSH_MODE_PROPERTY);
- propertyNames.add(HibernateNamedQuery.SPECIFIED_FLUSH_MODE_PROPERTY);
- }
-
- @Override
- protected FlushModeType[] getChoices() {
- return FlushModeType.values();
- }
-
- @Override
- protected FlushModeType getDefaultValue() {
- return getSubject().getDefaultFlushMode();
- }
-
- @Override
- protected String displayString(FlushModeType value) {
- return value.toString();
-
- }
-
- @Override
- protected FlushModeType getValue() {
- return getSubject().getSpecifiedFlushMode();
- }
-
- @Override
- protected void setValue(FlushModeType value) {
- getSubject().setSpecifiedFlushMode(value);
- }
- };
- }
-
- private EnumFormComboViewer<HibernateNamedQuery, CacheModeType>
addCacheModeTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<HibernateNamedQuery, CacheModeType>(this,
container) {
-
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(HibernateNamedQuery.DEFAULT_CACHE_MODE_PROPERTY);
- propertyNames.add(HibernateNamedQuery.SPECIFIED_CACHE_MODE_PROPERTY);
- }
-
- @Override
- protected CacheModeType[] getChoices() {
- return CacheModeType.values();
- }
-
- @Override
- protected CacheModeType getDefaultValue() {
- return getSubject().getDefaultCacheMode();
- }
-
- @Override
- protected String displayString(CacheModeType value) {
- return value.toString();
-
- }
-
- @Override
- protected CacheModeType getValue() {
- return getSubject().getSpecifiedCacheMode();
- }
-
- @Override
- protected void setValue(CacheModeType value) {
- getSubject().setSpecifiedCacheMode(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildCacheRegionTextHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_CACHE_REGION_PROPERTY,
- HibernateNamedQuery.SPECIFIED_CACHE_REGION_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getSpecifiedCacheRegion();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setSpecifiedCacheRegion(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildFetchSizeHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery,
Integer>(getSubjectHolder(), HibernateNamedQuery.SPECIFIED_FETCH_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedFetchSize();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedFetchSize(value);
- }
- };
- }
-
-
-
- private WritablePropertyValueModel<Integer> buildTimeoutHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery,
Integer>(getSubjectHolder(), HibernateNamedQuery.SPECIFIED_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedTimeout(value);
- }
- };
- }
-
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2009-07-13
08:56:40 UTC (rev 16543)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -46,6 +46,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.PageBook;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
@@ -53,12 +54,13 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateQueriesComposite extends Pane<QueryContainer> {
+public class HibernateQueriesComposite extends Pane<HibernateQueryContainer> {
private AddRemoveListPane<QueryContainer> listPane;
private NamedNativeQueryPropertyComposite namedNativeQueryPane;
private NamedQueryPropertyComposite namedQueryPane;
private HibernateNamedQueryPropertyComposite hibernateNamedQueryPane;
+ private HibernateNamedNativeQueryPropertyComposite hibernateNamedNativeQueryPane;
private WritablePropertyValueModel<Query> queryHolder;
/**
@@ -67,7 +69,7 @@
* @param parentPane The parent controller of this one
* @param parent The parent container
*/
- public HibernateQueriesComposite(Pane<? extends QueryContainer> parentPane,
+ public HibernateQueriesComposite(Pane<? extends HibernateQueryContainer>
parentPane,
Composite parent) {
super(parentPane, parent, false);
@@ -87,16 +89,18 @@
}
String queryType = hibernateAddQueryDialog.getQueryType();
Query query;
- HibernateQueryContainer subj = (HibernateQueryContainer)this.getSubject();
if (queryType == Query.NAMED_QUERY) {
query = this.getSubject().addNamedQuery(getSubject().namedQueriesSize());
}
else if (queryType == Query.NAMED_NATIVE_QUERY) {
- query = subj.addNamedNativeQuery(subj.namedNativeQueriesSize());
+ query =
this.getSubject().addNamedNativeQuery(this.getSubject().namedNativeQueriesSize());
}
else if (queryType == HibernateNamedQuery.HIBERNATE_NAMED_QUERY) {
- query = subj.addHibernateNamedQuery(subj.hibernateNamedQueriesSize());
+ query =
this.getSubject().addHibernateNamedQuery(this.getSubject().hibernateNamedQueriesSize());
}
+ else if (queryType == HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY) {
+ query =
this.getSubject().addHibernateNamedNativeQuery(this.getSubject().hibernateNamedNativeQueriesSize());
+ }
else {
throw new IllegalArgumentException();
}
@@ -166,7 +170,24 @@
}
};
}
+
+ private ListValueModel<HibernateNamedNativeQuery>
buildHibernateNamedNativeQueriesListHolder() {
+ return new ListAspectAdapter<QueryContainer, HibernateNamedNativeQuery>(
+ getSubjectHolder(),
+ HibernateQueryContainer.HIBERNATE_NAMED_NATIVE_QUERIES_LIST)
+ {
+ @Override
+ protected ListIterator<HibernateNamedNativeQuery> listIterator_() {
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueries();
+ }
+ @Override
+ protected int size_() {
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueriesSize();
+ }
+ };
+ }
+
private ListValueModel<NamedQuery> buildNamedQueriesListHolder() {
return new ListAspectAdapter<QueryContainer, NamedQuery>(
getSubjectHolder(),
@@ -201,6 +222,15 @@
}
};
}
+
+ private PropertyValueModel<HibernateNamedNativeQuery>
buildHibernateNamedNativeQueryHolder() {
+ return new TransformationPropertyValueModel<Query,
HibernateNamedNativeQuery>(this.queryHolder) {
+ @Override
+ protected HibernateNamedNativeQuery transform_(Query value) {
+ return (value instanceof HibernateNamedNativeQuery) ? (HibernateNamedNativeQuery)
value : null;
+ }
+ };
+ }
private Transformer<Query, Control> buildPaneTransformer() {
return new Transformer<Query, Control>() {
@@ -213,6 +243,10 @@
if (query instanceof HibernateNamedQuery) {
return HibernateQueriesComposite.this.hibernateNamedQueryPane.getControl();
}
+
+ if (query instanceof HibernateNamedNativeQuery){
+ return HibernateQueriesComposite.this.hibernateNamedNativeQueryPane.getControl();
+ }
if (query instanceof NamedNativeQuery) {
return HibernateQueriesComposite.this.namedNativeQueryPane.getControl();
@@ -234,7 +268,9 @@
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
for (Object item : listSelectionModel.selectedValues()) {
if (item instanceof HibernateNamedQuery) {
- ((HibernateQueryContainer)getSubject()).removeHibernateNamedQuery((HibernateNamedQuery)item);
+ getSubject().removeHibernateNamedQuery((HibernateNamedQuery)item);
+ } else if (item instanceof HibernateNamedNativeQuery) {
+ getSubject().removeHibernateNamedNativeQuery((HibernateNamedNativeQuery)item);
} else if (item instanceof NamedQuery) {
getSubject().removeNamedQuery((NamedQuery) item);
} else {
@@ -248,6 +284,7 @@
private ListValueModel<Query> buildQueriesListHolder() {
List<ListValueModel<? extends Query>> list = new
ArrayList<ListValueModel<? extends Query>>();
list.add(buildHibernateNamedQueriesListHolder());
+ list.add(buildHibernateNamedNativeQueriesListHolder());
list.add(buildNamedQueriesListHolder());
list.add(buildNamedNativeQueriesListHolder());
return new CompositeListValueModel<ListValueModel<? extends Query>,
Query>(list);
@@ -264,7 +301,9 @@
int index = -1;
if (query instanceof HibernateNamedQuery) {
- index =
CollectionTools.indexOf(((HibernateQueryContainer)getSubject()).hibernateNamedQueries(),
query);
+ index = CollectionTools.indexOf(getSubject().hibernateNamedQueries(), query);
+ } else if (query instanceof HibernateNamedNativeQuery) {
+ index = CollectionTools.indexOf(getSubject().hibernateNamedNativeQueries(),
query);
} else if (query instanceof NamedQuery) {
index = CollectionTools.indexOf(getSubject().namedQueries(), query);
} else {
@@ -305,13 +344,20 @@
PageBook pageBook = new PageBook(container, SWT.NULL);
pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // Named Query property pane
+ // Hibernate Named Query property pane
this.hibernateNamedQueryPane = new HibernateNamedQueryPropertyComposite(
this,
buildHibernateNamedQueryHolder(),
pageBook
);
+ // Hibernate Named Native Query property pane
+ this.hibernateNamedNativeQueryPane = new HibernateNamedNativeQueryPropertyComposite(
+ this,
+ buildHibernateNamedNativeQueryHolder(),
+ pageBook
+ );
+
// Named Query property pane
this.namedQueryPane = new NamedQueryPropertyComposite(
this,
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java 2009-07-13
10:17:39 UTC (rev 16544)
@@ -0,0 +1,485 @@
+/*******************************************************************************
+ * 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.ui.internal.mapping.details;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
+import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateQueryPropertyComposite<T extends HibernateQuery> extends
Pane<T> {
+
+ public HibernateQueryPropertyComposite(Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ addLabeledText(
+ container,
+ JptUiMappingsMessages.NamedQueryComposite_nameTextLabel,
+ buildNameTextHolder());
+
+ // Query text area
+ addLabeledMultiLineText(
+ container,
+ JptUiMappingsMessages.NamedQueryPropertyComposite_query,
+ buildQueryHolder(),
+ 4,
+ null
+ );
+
+ // ReadOnly tri-state check box
+ addTriStateCheckBoxWithDefault(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly,
+ buildReadOnlyHolder(),
+ buildReadOnlyStringHolder(),
+ null//TODO help
+ );
+
+ //Flush Mode combobox
+ addLabeledComposite(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_flushMode,
+ addFlushModeTypeCombo(container),
+ null//TODO help
+ );
+
+ // Cacheable tri-state check box
+ addTriStateCheckBoxWithDefault(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable,
+ buildCacheableHolder(),
+ buildCacheableStringHolder(),
+ null//TODO help
+ );
+
+ //Cache Mode combobox
+ addLabeledComposite(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheMode,
+ addCacheModeTypeCombo(container),
+ null//TODO help
+ );
+
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheRegion,
+ buildCacheRegionTextHolder());
+
+ // Fetch size widgets
+ Spinner fetchSizeSpinner = addLabeledSpinner(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_fetchSize,
+ buildFetchSizeHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ addDefaultFetchSizeLabel(container),
+ JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, fetchSizeSpinner);
+
+ // Timeout size widgets
+ Spinner timeoutSpinner = addLabeledSpinner(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_timeout,
+ buildTimeoutHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ addDefaultFetchSizeLabel(container),
+ JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, timeoutSpinner);
+
+ }
+
+ private Control addDefaultFetchSizeLabel(Composite container) {
+
+ Label label = addLabel(
+ container,
+ JptUiMappingsMessages.DefaultEmpty
+ );
+
+ new LabeledControlUpdater(
+ new LabeledLabel(label),
+ buildDefaultFetchSizeLabelHolder()
+ );
+
+ return label;
+ }
+
+ private PropertyValueModel<String> buildDefaultFetchSizeLabelHolder() {
+
+ return new TransformationPropertyValueModel<Integer,
String>(buildDefaultFetchSizeHolder()) {
+
+ @Override
+ protected String transform(Integer value) {
+
+ int defaultValue = (getSubject() != null) ? getSubject().getDefaultFetchSize() :
+ HibernateNamedQuery.DEFAULT_FETCH_SIZE;
+
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ Integer.valueOf(defaultValue)
+ );
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildDefaultFetchSizeHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(),
HibernateQuery.DEFAULT_FETCH_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultFetchSize());
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Integer.MIN_VALUE, newValue);
+ }
+ }
+ };
+ }
+
+ protected WritablePropertyValueModel<String> buildNameTextHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(
+ getSubjectHolder(), HibernateQuery.NAME_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setName(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildQueryHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(getSubjectHolder(),
HibernateQuery.QUERY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getQuery();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ this.subject.setQuery(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildCacheableHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Boolean>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_CACHEABLE_PROPERTY,
+ HibernateQuery.SPECIFIED_CACHEABLE_PROPERTY)
+ {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.getSpecifiedCacheable();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ this.subject.setSpecifiedCacheable(value);
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Boolean.TRUE, newValue);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<String> buildCacheableStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean,
String>(buildCacheableHolder()) {
+
+ @Override
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultCacheable();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheableWithDefault,
+ defaultStringValue
+ );
+ }
+
+ return HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildReadOnlyHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Boolean>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_READ_ONLY_PROPERTY,
+ HibernateQuery.SPECIFIED_READ_ONLY_PROPERTY)
+ {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.getSpecifiedReadOnly();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ this.subject.setSpecifiedReadOnly(value);
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Boolean.TRUE, newValue);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<String> buildReadOnlyStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean,
String>(buildReadOnlyHolder()) {
+
+ @Override
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultReadOnly();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnlyWithDefault,
+ defaultStringValue
+ );
+ }
+
+ return HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly;
+ }
+ };
+ }
+
+ private EnumFormComboViewer<HibernateQuery, FlushModeType>
addFlushModeTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<HibernateQuery, FlushModeType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(HibernateQuery.DEFAULT_FLUSH_MODE_PROPERTY);
+ propertyNames.add(HibernateQuery.SPECIFIED_FLUSH_MODE_PROPERTY);
+ }
+
+ @Override
+ protected FlushModeType[] getChoices() {
+ return FlushModeType.values();
+ }
+
+ @Override
+ protected FlushModeType getDefaultValue() {
+ return getSubject().getDefaultFlushMode();
+ }
+
+ @Override
+ protected String displayString(FlushModeType value) {
+ return value.toString();
+
+ }
+
+ @Override
+ protected FlushModeType getValue() {
+ return getSubject().getSpecifiedFlushMode();
+ }
+
+ @Override
+ protected void setValue(FlushModeType value) {
+ getSubject().setSpecifiedFlushMode(value);
+ }
+ };
+ }
+
+ private EnumFormComboViewer<HibernateQuery, CacheModeType>
addCacheModeTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<HibernateQuery, CacheModeType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(HibernateQuery.DEFAULT_CACHE_MODE_PROPERTY);
+ propertyNames.add(HibernateQuery.SPECIFIED_CACHE_MODE_PROPERTY);
+ }
+
+ @Override
+ protected CacheModeType[] getChoices() {
+ return CacheModeType.values();
+ }
+
+ @Override
+ protected CacheModeType getDefaultValue() {
+ return getSubject().getDefaultCacheMode();
+ }
+
+ @Override
+ protected String displayString(CacheModeType value) {
+ return value.toString();
+
+ }
+
+ @Override
+ protected CacheModeType getValue() {
+ return getSubject().getSpecifiedCacheMode();
+ }
+
+ @Override
+ protected void setValue(CacheModeType value) {
+ getSubject().setSpecifiedCacheMode(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildCacheRegionTextHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_CACHE_REGION_PROPERTY,
+ HibernateQuery.SPECIFIED_CACHE_REGION_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getSpecifiedCacheRegion();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setSpecifiedCacheRegion(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildFetchSizeHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(),
HibernateQuery.SPECIFIED_FETCH_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedFetchSize();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value.intValue() == -1) {
+ value = null;
+ }
+ this.subject.setSpecifiedFetchSize(value);
+ }
+ };
+ }
+
+
+
+ private WritablePropertyValueModel<Integer> buildTimeoutHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(),
HibernateQuery.SPECIFIED_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value.intValue() == -1) {
+ value = null;
+ }
+ this.subject.setSpecifiedTimeout(value);
+ }
+ };
+ }
+
+ protected void updateGridData(Composite container, Spinner spinner) {
+
+ // It is possible the spinner's parent is not the container of the
+ // label, spinner and right control (a pane is sometimes required for
+ // painting the spinner's border)
+ Composite paneContainer = spinner.getParent();
+
+ while (container != paneContainer.getParent()) {
+ paneContainer = paneContainer.getParent();
+ }
+
+ Control[] controls = paneContainer.getChildren();
+
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = false;
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ controls[1].setLayoutData(gridData);
+
+ controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeAlignRight(controls[2]);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native