Hibernate SVN: r10681 - in branches/Lucene_Integration/HibernateExt/metadata/src: java/org/hibernate/lucene java/org/hibernate/lucene/annotations java/org/hibernate/lucene/backend java/org/hibernate/lucene/backend/impl java/org/hibernate/lucene/bridge java/org/hibernate/lucene/engine java/org/hibernate/lucene/event java/org/hibernate/lucene/query java/org/hibernate/lucene/store java/org/hibernate/lucene/util test/org/hibernate/lucene/test test/org/hibernate/lucene/test/bridge test/org/hi
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 18:06:05 -0500 (Wed, 01 Nov 2006)
New Revision: 10681
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java
Log:
ANN-483 package refactoring
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,20 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Apply a boost factor on a field or a whole entity
- *
- * @author Emmanuel Bernard
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface Boost {
- float value();
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-import org.hibernate.lucene.bridge.Resolution;
-
-/**
- * Defines the temporal resolution of a given field
- * Date are stored as String in GMT
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-@Documented
-//TODO allow pattern yyyyMMdd?
-public @interface DateBridge {
- Resolution value();
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,318 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.io.Serializable;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.Term;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.annotations.Version;
-import org.hibernate.lucene.bridge.BridgeFactory;
-import org.hibernate.lucene.bridge.FieldBridge;
-import org.hibernate.lucene.bridge.IdFieldBridge;
-import org.hibernate.lucene.event.LuceneEventListener;
-import org.hibernate.lucene.store.DirectoryProvider;
-import org.hibernate.lucene.util.BinderHelper;
-import org.hibernate.reflection.ReflectionManager;
-import org.hibernate.reflection.XAnnotatedElement;
-import org.hibernate.reflection.XClass;
-import org.hibernate.reflection.XMember;
-import org.hibernate.reflection.XProperty;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * Set up and provide a manager for indexes classes
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- * @author Richard Hallier
- */
-public class DocumentBuilder<T> {
-
- static {
- Version.touch(); //touch version
- }
-
- private final List<XMember> keywordGetters = new ArrayList<XMember>();
- private final List<String> keywordNames = new ArrayList<String>();
- private final List<FieldBridge> keywordBridges = new ArrayList<FieldBridge>();
- private final List<XMember> unstoredGetters = new ArrayList<XMember>();
- private final List<String> unstoredNames = new ArrayList<String>();
- private final List<FieldBridge> unstoredBridges = new ArrayList<FieldBridge>();
- private final List<XMember> textGetters = new ArrayList<XMember>();
- private final List<String> textNames = new ArrayList<String>();
- private final List<FieldBridge> textBridges = new ArrayList<FieldBridge>();
- private final List<String> fieldNames = new ArrayList<String>();
- private final List<XMember> fieldGetters = new ArrayList<XMember>();
- private final List<FieldBridge> fieldBridges = new ArrayList<FieldBridge>();
- private final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
- private final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
-
- private final XClass beanClass;
- private final DirectoryProvider directoryProvider;
- private String idKeywordName;
- private final Analyzer analyzer;
- private Float idBoost;
- public static final String CLASS_FIELDNAME = "_hibernate_class";
- private IdFieldBridge idBridge;
- private Set<Class> mappedSubclasses = new HashSet<Class>();
- private ReflectionManager reflectionManager;
-
-
- public DocumentBuilder(XClass clazz, Analyzer analyzer, DirectoryProvider directory, ReflectionManager reflectionManager) {
- this.beanClass = clazz;
- this.analyzer = analyzer;
- this.directoryProvider = directory;
- //FIXME get rid of it when boost is stored?
- this.reflectionManager = reflectionManager;
-
- if (clazz == null) throw new AssertionFailure("Unable to build a DocumentBuilder with a null class");
-
- for ( XClass currClass = beanClass; currClass != null; currClass = currClass.getSuperclass() ) {
- //rejecting non properties because the object is loaded from Hibernate, so indexing a non property does not make sense
- List<XProperty> methods = currClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
- for ( XProperty method : methods ) {
- initializeMember( method );
- }
-
- List<XProperty> fields = currClass.getDeclaredProperties( XClass.ACCESS_FIELD );
- for ( XProperty field : fields ) {
- initializeMember( field );
- }
- }
-
- if ( idKeywordName == null ) {
- throw new HibernateException( "No document id for: " + clazz.getName() );
- }
- }
-
- private void initializeMember(XMember member) {
- Keyword keywordAnn = member.getAnnotation( Keyword.class );
- if ( keywordAnn != null ) {
- String name = BinderHelper.getAttributeName( member, keywordAnn.name() );
- if ( keywordAnn.id() ) {
- idKeywordName = name;
- idBoost = getBoost( member );
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
- if ( fieldBridge instanceof IdFieldBridge ) {
- idBridge = (IdFieldBridge) fieldBridge;
- }
- else {
- throw new HibernateException( "Bridge for document id does not implement IdFieldBridge: " + member.getName() );
- }
- }
- else {
- setAccessible( member );
- keywordGetters.add( member );
- keywordNames.add( name );
- keywordBridges.add( BridgeFactory.guessType( member ) );
- }
- }
-
- Unstored unstoredAnn = member.getAnnotation( Unstored.class );
- if ( unstoredAnn != null ) {
- setAccessible( member );
- unstoredGetters.add( member );
- unstoredNames.add( BinderHelper.getAttributeName( member, unstoredAnn.name() ) );
- unstoredBridges.add( BridgeFactory.guessType( member ) );
- }
-
- Text textAnn = member.getAnnotation( Text.class );
- if ( textAnn != null ) {
- setAccessible( member );
- textGetters.add( member );
- textNames.add( BinderHelper.getAttributeName( member, textAnn.name() ) );
- textBridges.add( BridgeFactory.guessType( member ) );
- }
-
- DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
- if ( documentIdAnn != null ) {
- if ( idKeywordName != null ) {
- throw new AssertionFailure( "Two document id assigned: "
- + idKeywordName + " and " + BinderHelper.getAttributeName( member, documentIdAnn.name() ) );
- }
- idKeywordName = BinderHelper.getAttributeName( member, documentIdAnn.name() );
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
- if ( fieldBridge instanceof IdFieldBridge ) {
- idBridge = (IdFieldBridge) fieldBridge;
- }
- else {
- throw new HibernateException( "Bridge for document id does not implement IdFieldBridge: " + member.getName() );
- }
- idBoost = getBoost( member );
- }
-
- org.hibernate.lucene.Field fieldAnn = member.getAnnotation( org.hibernate.lucene.Field.class );
- if ( fieldAnn != null ) {
- setAccessible( member );
- fieldGetters.add( member );
- fieldNames.add( BinderHelper.getAttributeName( member, fieldAnn.name() ) );
- fieldStore.add( getStore( fieldAnn.store() ) );
- fieldIndex.add( getIndex( fieldAnn.index() ) );
- fieldBridges.add( BridgeFactory.guessType( member ) );
- }
- }
-
- private Field.Store getStore(Store store) {
- switch( store ) {
- case NO:
- return Field.Store.NO;
- case YES:
- return Field.Store.YES;
- case COMPRESS:
- return Field.Store.COMPRESS;
- default:
- throw new AssertionFailure( "Unexpected Store: " + store );
- }
- }
-
- private Field.Index getIndex(Index index) {
- switch( index ) {
- case NO:
- return Field.Index.NO;
- case NO_NORMS:
- return Field.Index.NO_NORMS;
- case TOKENIZED:
- return Field.Index.TOKENIZED;
- case UN_TOKENISED:
- return Field.Index.UN_TOKENIZED;
- default:
- throw new AssertionFailure( "Unexpected Index: " + index );
- }
- }
-
- private Float getBoost(XAnnotatedElement element) {
- if ( element == null ) return null;
- Boost boost = element.getAnnotation( Boost.class );
- return boost != null ?
- boost.value() :
- null;
- }
-
- private Object getMemberValue(T bean, XMember getter) {
- Object value;
- try {
- value = getter.invoke( bean );
- }
- catch (Exception e) {
- throw new IllegalStateException( "Could not get property value", e );
- }
- return value;
- }
-
- public Document getDocument(T instance, Serializable id) {
- Document doc = new Document();
- XClass instanceClass = reflectionManager.toXClass( instance.getClass() );
- Float boost = getBoost( instanceClass );
- if ( boost != null ) {
- doc.setBoost( boost );
- }
- {
- Field classField =
- new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED );
- doc.add( classField );
- idBridge.set( idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, idBoost );
- }
- for ( int i = 0; i < keywordNames.size(); i++ ) {
- XMember member = keywordGetters.get( i );
- Object value = getMemberValue( instance, member );
- keywordBridges.get( i ).set(
- keywordNames.get( i ), value, doc, Field.Store.YES,
- Field.Index.UN_TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < textNames.size(); i++ ) {
- XMember member = textGetters.get( i );
- Object value = getMemberValue( instance, member );
- textBridges.get( i ).set(
- textNames.get( i ), value, doc, Field.Store.YES,
- Field.Index.TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < unstoredNames.size(); i++ ) {
- XMember member = unstoredGetters.get( i );
- Object value = getMemberValue( instance, member );
- unstoredBridges.get( i ).set(
- unstoredNames.get( i ), value, doc, Field.Store.NO,
- Field.Index.TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < fieldNames.size(); i++ ) {
- XMember member = fieldGetters.get( i );
- Object value = getMemberValue( instance, member );
- fieldBridges.get( i ).set(
- fieldNames.get( i ), value, doc, fieldStore.get( i ),
- fieldIndex.get( i ), getBoost( member )
- );
- }
- return doc;
- }
-
- public Term getTerm(Serializable id) {
- return new Term( idKeywordName, idBridge.objectToString( id ) );
- }
-
- public DirectoryProvider getDirectoryProvider() {
- return directoryProvider;
- }
-
- public Analyzer getAnalyzer() {
- return analyzer;
- }
-
- private static void setAccessible(XMember member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- member.setAccessible( true );
- }
- }
-
- public IdFieldBridge getIdBridge() {
- return idBridge;
- }
-
- public String getIdKeywordName() {
- return idKeywordName;
- }
-
- public static Class getDocumentClass(Document document) {
- String className = document.get( DocumentBuilder.CLASS_FIELDNAME );
- try {
- return ReflectHelper.classForName( className );
- }
- catch (ClassNotFoundException e) {
- throw new HibernateException( "Unable to load indexed class: " + className, e );
- }
- }
-
- public static Serializable getDocumentId(LuceneEventListener listener, Class clazz, Document document) {
- DocumentBuilder builder = listener.getDocumentBuilders().get( clazz );
- if ( builder == null ) throw new HibernateException( "No Lucene configuration set up for: " + clazz.getName() );
- return (Serializable) builder.getIdBridge().get( builder.getIdKeywordName(), document );
- }
-
- public void postInitialize(Set<Class> indexedClasses) {
- //this method does not requires synchronization
- Class plainClass = reflectionManager.toClass( beanClass );
- Set<Class> tempMappedSubclasses = new HashSet<Class>();
- //together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
- for ( Class currentClass : indexedClasses ) {
- if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add( currentClass );
- }
- mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
- }
-
-
- public Set<Class> getMappedSubclasses() {
- return mappedSubclasses;
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,22 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Declare a field as the document id. If set to a property, the property will be used
- * TODO: If set to a class, the class itself will be passed to the FieldBridge
- * Note that @{link org.hibernate.lucene.bridge.FieldBridge#get} must return the Entity id
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface DocumentId {
- String name() default "";
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,38 +0,0 @@
-//$Id: $
-/**
- * JavaDoc copy/pastle from the Apache Lucene project
- * Available under the ASL 2.0 http://www.apache.org/licenses/LICENSE-2.0
- */
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Mark a property as indexable
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface Field {
- /**
- * Field name, default to the JavaBean property name
- */
- String name() default "";
-
- /**
- * Should the value be stored in the document
- */
- Store store() default Store.NO;
-
- /**
- * Defines how the Field should be indexed
- */
- Index index();
-
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,22 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-import org.hibernate.annotations.Parameter;
-
-/**
- * specifies a given field bridge implementation
- * @author Emmanuel Bernard
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-@Documented
-public @interface FieldBridge {
- public Class impl() default void.class;
- public Parameter[] params() default {};
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,29 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-/**
- * Defines how an Field should be indexed
- */
-public enum Index {
- /** Do not index the field value. This field can thus not be searched,
- * but one can still access its contents provided it is
- * {@link Store stored}. */
- NO,
- /** Index the field's value so it can be searched. An Analyzer will be used
- * to tokenize and possibly further normalize the text before its
- * terms will be stored in the index. This is useful for common text.
- */
- TOKENIZED,
- /** Index the field's value without using an Analyzer, so it can be searched.
- * As no analyzer is used the value will be stored as a single term. This is
- * useful for unique Ids like product numbers.
- */
- UN_TOKENISED,
- /** Index the field's value without an Analyzer, and disable
- * the storing of norms. No norms means that index-time boosting
- * and field length normalization will be disabled. The benefit is
- * less memory usage as norms take up one byte per indexed field
- * for every document in the index.
- */
- NO_NORMS
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,21 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-@Documented
-/**
- * Specifies that an entity is to be indexed by Lucene
- */
-public @interface Indexed {
- /**
- * The filename of the index
- */
- String index() default "";
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,28 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * keyword field
- * @deprecated use @Field(index=Index.UN_TOKENIZED, store=Store.YES) or @DocumentId when id=true was used
- */
-@Deprecated
-public @interface Keyword {
- /**
- * The field name
- */
- String name() default "";
- /**
- * Specifies that this is the "identifier" keyword
- */
- boolean id() default false;
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,13 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-/**
- * Whether or not the value is stored in the document
- *
- * @author Emmanuel Bernard
- */
-public enum Store {
- NO,
- YES,
- COMPRESS
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * text field
- * @deprecated use @Field(index=Index.TOKENIZED, store=Store.YES)
- */
-@Deprecated
-public @interface Text {
- /**
- * The field name
- */
- String name() default "";
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * unstored field
- * @deprecated use @Field(index=Index.TOKENIZED, store=Store.NO)
- */
-@Deprecated
-public @interface Unstored {
- /**
- * The field name
- */
- String name() default "";
-}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java (from rev 10577, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-10-13 22:27:43 UTC (rev 10577)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,20 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Apply a boost factor on a field or a whole entity
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.TYPE, ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface Boost {
+ float value();
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java (from rev 10600, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-10-17 23:58:05 UTC (rev 10600)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.hibernate.lucene.bridge.Resolution;
+
+/**
+ * Defines the temporal resolution of a given field
+ * Date are stored as String in GMT
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.FIELD, ElementType.METHOD} )
+@Documented
+//TODO allow pattern like yyyyMMdd?
+public @interface DateBridge {
+ Resolution value();
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,22 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declare a field as the document id. If set to a property, the property will be used
+ * TODO: If set to a class, the class itself will be passed to the FieldBridge
+ * Note that @{link org.hibernate.lucene.bridge.FieldBridge#get} must return the Entity id
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface DocumentId {
+ String name() default "";
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,38 @@
+//$Id: $
+/**
+ * JavaDoc copy/pastle from the Apache Lucene project
+ * Available under the ASL 2.0 http://www.apache.org/licenses/LICENSE-2.0
+ */
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Mark a property as indexable
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface Field {
+ /**
+ * Field name, default to the JavaBean property name
+ */
+ String name() default "";
+
+ /**
+ * Should the value be stored in the document
+ */
+ Store store() default Store.NO;
+
+ /**
+ * Defines how the Field should be indexed
+ */
+ Index index();
+
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java (from rev 10565, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.hibernate.annotations.Parameter;
+
+/**
+ * specifies a given field bridge implementation
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.FIELD, ElementType.METHOD} )
+@Documented
+public @interface FieldBridge {
+ public Class impl() default void.class;
+
+ public Parameter[] params() default {};
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,34 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+/**
+ * Defines how an Field should be indexed
+ */
+public enum Index {
+ /**
+ * Do not index the field value. This field can thus not be searched,
+ * but one can still access its contents provided it is
+ * {@link Store stored}.
+ */
+ NO,
+ /**
+ * Index the field's value so it can be searched. An Analyzer will be used
+ * to tokenize and possibly further normalize the text before its
+ * terms will be stored in the index. This is useful for common text.
+ */
+ TOKENIZED,
+ /**
+ * Index the field's value without using an Analyzer, so it can be searched.
+ * As no analyzer is used the value will be stored as a single term. This is
+ * useful for unique Ids like product numbers.
+ */
+ UN_TOKENISED,
+ /**
+ * Index the field's value without an Analyzer, and disable
+ * the storing of norms. No norms means that index-time boosting
+ * and field length normalization will be disabled. The benefit is
+ * less memory usage as norms take up one byte per indexed field
+ * for every document in the index.
+ */
+ NO_NORMS
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java (from rev 10565, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,21 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+/**
+ * Specifies that an entity is to be indexed by Lucene
+ */
+public @interface Indexed {
+ /**
+ * The filename of the index
+ */
+ String index() default "";
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * keyword field
+ * @deprecated use @Field(index=Index.UN_TOKENIZED, store=Store.YES) or @DocumentId when id=true was used
+ */
+@Deprecated
+public @interface Keyword {
+ /**
+ * The field name
+ */
+ String name() default "";
+
+ /**
+ * Specifies that this is the "identifier" keyword
+ */
+ boolean id() default false;
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,13 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+/**
+ * Whether or not the value is stored in the document
+ *
+ * @author Emmanuel Bernard
+ */
+public enum Store {
+ NO,
+ YES,
+ COMPRESS
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * text field
+ * @deprecated use @Field(index=Index.TOKENIZED, store=Store.YES)
+ */
+@Deprecated
+public @interface Text {
+ /**
+ * The field name
+ */
+ String name() default "";
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * unstored field
+ * @deprecated use @Field(index=Index.TOKENIZED, store=Store.NO)
+ */
+@Deprecated
+public @interface Unstored {
+ /**
+ * The field name
+ */
+ String name() default "";
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AddWork extends Work {
+ public AddWork(Serializable id, Class entity, Document document) {
+ super( id, entity, document );
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,13 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DeleteWork extends Work {
+ public DeleteWork(Serializable id, Class entity) {
+ super( id, entity );
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class UpdateWork extends Work {
+ public UpdateWork(Serializable id, Class entity, Document document) {
+ super( id, entity, document );
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,40 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * Represent a Lucene unit work
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class Work implements Serializable {
+ private Document document;
+ private Class entity;
+ private Serializable id;
+
+ public Work(Serializable id, Class entity) {
+ this( id, entity, null );
+ }
+
+ public Work(Serializable id, Class entity, Document document) {
+ this.id = id;
+ this.entity = entity;
+ this.document = document;
+ }
+
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public Class getEntity() {
+ return entity;
+ }
+
+ public Serializable getId() {
+ return id;
+ }
+}
Added: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+/**
+ * Set of work operations
+ *
+ * @author Emmanuel Bernard
+ */
+public interface WorkQueue {
+ /**
+ * Add a work
+ */
+ void add(Work work);
+
+ /**
+ * Execute works
+ */
+ void performWork();
+
+ /**
+ * Rollback works
+ */
+ void cancelWork();
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,137 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.hibernate.HibernateException;
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.store.DirectoryProvider;
+
+/**
+ * Lucene workspace
+ * This is not intended to be used in a multithreaded environment
+ * <p/>
+ * One cannot execute modification through an IndexReader when an IndexWriter has been acquired on the same underlying directory
+ * One cannot get an IndexWriter when an IndexReader have been acquired and modificed on the same underlying directory
+ * The recommended approach is to execute all the modifications on the IndexReaders, {@link #clean()} }, and acquire the
+ * index writers
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene use abstract classes, not interfaces
+public class Workspace {
+ private static Log log = LogFactory.getLog( Workspace.class );
+ private Map<Class, DocumentBuilder<Object>> documentBuilders;
+ private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders;
+ private Map<DirectoryProvider, IndexReader> readers = new HashMap<DirectoryProvider, IndexReader>();
+ private Map<DirectoryProvider, IndexWriter> writers = new HashMap<DirectoryProvider, IndexWriter>();
+ private List<DirectoryProvider> lockedProviders = new ArrayList<DirectoryProvider>();
+
+ public Workspace(Map<Class, DocumentBuilder<Object>> documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ this.documentBuilders = documentBuilders;
+ this.lockableDirectoryProviders = lockableDirectoryProviders;
+ }
+
+
+ public DocumentBuilder getDocumentBuilder(Class entity) {
+ return documentBuilders.get( entity );
+ }
+
+ public IndexReader getIndexReader(Class entity) {
+ //TODO NPEs
+ DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
+ IndexReader reader = readers.get( provider );
+ if ( reader != null ) return reader;
+ lockProvider( provider );
+ try {
+ reader = IndexReader.open( provider.getDirectory() );
+ readers.put( provider, reader );
+ }
+ catch (IOException e) {
+ cleanUp( new HibernateException( "Unable to open IndexReader for " + entity, e ) );
+ }
+ return reader;
+ }
+
+ public IndexWriter getIndexWriter(Class entity) {
+ DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
+ IndexWriter writer = writers.get( provider );
+ if ( writer != null ) return writer;
+ lockProvider( provider );
+ try {
+ writer = new IndexWriter(
+ provider.getDirectory(), documentBuilders.get( entity ).getAnalyzer(), false
+ ); //have been created at init time
+ writers.put( provider, writer );
+ }
+ catch (IOException e) {
+ cleanUp( new HibernateException( "Unable to open IndexWriter for " + entity, e ) );
+ }
+ return writer;
+ }
+
+ private void lockProvider(DirectoryProvider provider) {
+ //make sure to use a semaphore
+ ReentrantLock lock = lockableDirectoryProviders.get( provider );
+ //of course a given thread cannot have a race cond with itself
+ if ( !lock.isHeldByCurrentThread() ) {
+ lock.lock();
+ lockedProviders.add( provider );
+ }
+ }
+
+ private void cleanUp(HibernateException originalException) {
+ //release all readers and writers, then reelase locks
+ HibernateException raisedException = originalException;
+ for ( IndexReader reader : readers.values() ) {
+ try {
+ reader.close();
+ }
+ catch (IOException e) {
+ if ( raisedException != null ) {
+ log.error( "Subsequent Exception while closing IndexReader", e );
+ }
+ else {
+ raisedException = new HibernateException( "Exception while closing IndexReader", e );
+ }
+ }
+ }
+ for ( IndexWriter writer : writers.values() ) {
+ try {
+ writer.close();
+ }
+ catch (IOException e) {
+ if ( raisedException != null ) {
+ log.error( "Subsequent Exception while closing IndexWriter", e );
+ }
+ else {
+ raisedException = new HibernateException( "Exception while closing IndexWriter", e );
+ }
+ }
+ }
+ for ( DirectoryProvider provider : lockedProviders ) {
+ lockableDirectoryProviders.get( provider ).unlock();
+ }
+ readers.clear();
+ writers.clear();
+ lockedProviders.clear();
+ if ( raisedException != null ) throw raisedException;
+ }
+
+ /**
+ * release resources consumed in the workspace if any
+ */
+ public void clean() {
+ cleanUp( null );
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,65 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.lucene.backend.impl.LuceneWorker;
+import org.hibernate.lucene.backend.WorkQueue;
+import org.hibernate.lucene.backend.Workspace;
+import org.hibernate.lucene.backend.Work;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.AddWork;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class BatchLuceneWorkQueue implements WorkQueue {
+ private Workspace workspace;
+ private LuceneWorker worker;
+ private List<Work> queue = new ArrayList<Work>();
+
+ public BatchLuceneWorkQueue(Map<Class, DocumentBuilder<Object>> documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ workspace = new Workspace( documentBuilders, lockableDirectoryProviders );
+ worker = new LuceneWorker( workspace );
+ }
+
+ public void add(Work work) {
+ //TODO optimize by getting rid of dupe works
+ if ( work instanceof UpdateWork ) {
+ //split in 2 to optimize the process (reader first, writer next
+ queue.add( new DeleteWork( work.getId(), work.getEntity() ) );
+ queue.add( new AddWork( work.getId(), work.getEntity(), work.getDocument() ) );
+ }
+ else {
+ queue.add( work );
+ }
+ }
+
+ public void performWork() {
+ try {
+ //use of index reader
+ for ( Work work : queue ) {
+ if ( work instanceof DeleteWork ) worker.performWork( work );
+ }
+ workspace.clean(); //close readers
+ for ( Work work : queue ) {
+ if ( work instanceof AddWork ) worker.performWork( work );
+ }
+ }
+ finally {
+ workspace.clean();
+ queue.clear();
+ }
+ }
+
+ public void cancelWork() {
+ queue.clear();
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java (from rev 10674, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,116 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.backend.Workspace;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.AddWork;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.Work;
+
+/**
+ * Stateless implementation that perform a work
+ *
+ * @author Emmanuel Bernard
+ */
+public class LuceneWorker {
+ private Workspace workspace;
+ private static Log log = LogFactory.getLog( LuceneWorker.class );
+
+ public LuceneWorker(Workspace workspace) {
+ this.workspace = workspace;
+ }
+
+ public void performWork(Work work) {
+ if ( AddWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (AddWork) work );
+ }
+ else if ( UpdateWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (UpdateWork) work );
+ }
+ else if ( DeleteWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (DeleteWork) work );
+ }
+ else {
+ throw new AssertionFailure( "Unknown work type: " + work.getClass() );
+ }
+ }
+
+ public void performWork(AddWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ Document document = work.getDocument();
+ add( entity, id, document );
+ }
+
+ private void add(Class entity, Serializable id, Document document) {
+ if ( log.isTraceEnabled() )
+ log.trace( "add to Lucene index: " + entity + "#" + id + ": " + document );
+ IndexWriter writer = workspace.getIndexWriter( entity );
+ try {
+ writer.addDocument( document );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to add to Lucene index: " + entity + "#" + id, e );
+ }
+ }
+
+ public void performWork(UpdateWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ Document document = work.getDocument();
+ remove( entity, id );
+ add( entity, id, document );
+ }
+
+ public void performWork(DeleteWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ remove( entity, id );
+ }
+
+ private void remove(Class entity, Serializable id) {
+ log.trace( "remove from Lucene index: " + entity + "#" + id );
+ DocumentBuilder builder = workspace.getDocumentBuilder( entity );
+ Term term = builder.getTerm( id );
+ IndexReader reader = workspace.getIndexReader( entity );
+ TermDocs termDocs = null;
+ try {
+ //TODO is there a faster way?
+ //TODO include TermDocs into the workspace?
+ termDocs = reader.termDocs( term );
+ String entityName = entity.getName();
+ while ( termDocs.next() ) {
+ int docIndex = termDocs.doc();
+ if ( entityName.equals( reader.document( docIndex ).get( DocumentBuilder.CLASS_FIELDNAME ) ) ) {
+ //remove only the one of the right class
+ //loop all to remove all the matches (defensive code)
+ reader.deleteDocument( docIndex );
+ }
+ }
+ }
+ catch (Exception e) {
+ throw new HibernateException( "Unable to remove from Lucene index: " + entity + "#" + id, e );
+ }
+ finally {
+ if (termDocs != null) try {
+ termDocs.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to close termDocs properly", e);
+ }
+ }
+ }
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,36 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.hibernate.lucene.backend.WorkQueue;
+
+/**
+ * Execute some work inside a transaction sychronization
+ *
+ * @author Emmanuel Bernard
+ */
+public class PostTransactionWorkQueueSynchronization implements Synchronization {
+ private WorkQueue workQueue;
+
+ public PostTransactionWorkQueueSynchronization(WorkQueue workQueue) {
+ this.workQueue = workQueue;
+ }
+
+ public void beforeCompletion() {
+ }
+
+ public void afterCompletion(int i) {
+ if ( Status.STATUS_COMMITTED == i ) {
+ workQueue.performWork();
+ }
+ else {
+ workQueue.cancelWork();
+ }
+ }
+
+ public static interface Work {
+ void perform();
+ }
+}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -9,7 +9,6 @@
import org.hibernate.HibernateException;
import org.hibernate.annotations.Parameter;
-import org.hibernate.lucene.DateBridge;
import org.hibernate.reflection.XClass;
import org.hibernate.reflection.XMember;
@@ -69,7 +68,8 @@
public static FieldBridge guessType(XMember member) {
FieldBridge bridge = null;
- org.hibernate.lucene.FieldBridge bridgeAnn = member.getAnnotation( org.hibernate.lucene.FieldBridge.class );
+ org.hibernate.lucene.annotations.FieldBridge bridgeAnn =
+ member.getAnnotation( org.hibernate.lucene.annotations.FieldBridge.class );
if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
try {
@@ -93,8 +93,8 @@
throw new HibernateException( "Unable to instanciate FieldBridge for " + member.getName(), e );
}
}
- else if ( member.isAnnotationPresent( DateBridge.class ) ) {
- Resolution resolution = member.getAnnotation( DateBridge.class ).value();
+ else if ( member.isAnnotationPresent( org.hibernate.lucene.annotations.DateBridge.class ) ) {
+ Resolution resolution = member.getAnnotation( org.hibernate.lucene.annotations.DateBridge.class ).value();
bridge = org.hibernate.lucene.bridge.DateBridge.getDateField( resolution );
}
else {
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java (from rev 10678, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -0,0 +1,329 @@
+//$Id$
+package org.hibernate.lucene.engine;
+
+import java.io.Serializable;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.Term;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.annotations.Version;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Store;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Unstored;
+import org.hibernate.lucene.bridge.BridgeFactory;
+import org.hibernate.lucene.bridge.FieldBridge;
+import org.hibernate.lucene.bridge.IdFieldBridge;
+import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.lucene.util.BinderHelper;
+import org.hibernate.reflection.ReflectionManager;
+import org.hibernate.reflection.XAnnotatedElement;
+import org.hibernate.reflection.XClass;
+import org.hibernate.reflection.XMember;
+import org.hibernate.reflection.XProperty;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Set up and provide a manager for indexes classes
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ * @author Richard Hallier
+ */
+public class DocumentBuilder<T> {
+
+ static {
+ Version.touch(); //touch version
+ }
+
+ private final List<XMember> keywordGetters = new ArrayList<XMember>();
+ private final List<String> keywordNames = new ArrayList<String>();
+ private final List<FieldBridge> keywordBridges = new ArrayList<FieldBridge>();
+ private final List<XMember> unstoredGetters = new ArrayList<XMember>();
+ private final List<String> unstoredNames = new ArrayList<String>();
+ private final List<FieldBridge> unstoredBridges = new ArrayList<FieldBridge>();
+ private final List<XMember> textGetters = new ArrayList<XMember>();
+ private final List<String> textNames = new ArrayList<String>();
+ private final List<FieldBridge> textBridges = new ArrayList<FieldBridge>();
+ private final List<String> fieldNames = new ArrayList<String>();
+ private final List<XMember> fieldGetters = new ArrayList<XMember>();
+ private final List<FieldBridge> fieldBridges = new ArrayList<FieldBridge>();
+ private final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
+ private final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
+
+ private final XClass beanClass;
+ private final DirectoryProvider directoryProvider;
+ private String idKeywordName;
+ private final Analyzer analyzer;
+ private Float idBoost;
+ public static final String CLASS_FIELDNAME = "_hibernate_class";
+ private IdFieldBridge idBridge;
+ private Set<Class> mappedSubclasses = new HashSet<Class>();
+ private ReflectionManager reflectionManager;
+
+
+ public DocumentBuilder(XClass clazz, Analyzer analyzer, DirectoryProvider directory,
+ ReflectionManager reflectionManager) {
+ this.beanClass = clazz;
+ this.analyzer = analyzer;
+ this.directoryProvider = directory;
+ //FIXME get rid of it when boost is stored?
+ this.reflectionManager = reflectionManager;
+
+ if ( clazz == null ) throw new AssertionFailure( "Unable to build a DocumentBuilder with a null class" );
+
+ for ( XClass currClass = beanClass; currClass != null; currClass = currClass.getSuperclass() ) {
+ //rejecting non properties because the object is loaded from Hibernate, so indexing a non property does not make sense
+ List<XProperty> methods = currClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
+ for ( XProperty method : methods ) {
+ initializeMember( method );
+ }
+
+ List<XProperty> fields = currClass.getDeclaredProperties( XClass.ACCESS_FIELD );
+ for ( XProperty field : fields ) {
+ initializeMember( field );
+ }
+ }
+
+ if ( idKeywordName == null ) {
+ throw new HibernateException( "No document id for: " + clazz.getName() );
+ }
+ }
+
+ private void initializeMember(XProperty member) {
+ Keyword keywordAnn = member.getAnnotation( Keyword.class );
+ if ( keywordAnn != null ) {
+ String name = BinderHelper.getAttributeName( member, keywordAnn.name() );
+ if ( keywordAnn.id() ) {
+ idKeywordName = name;
+ idBoost = getBoost( member );
+ FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ if ( fieldBridge instanceof IdFieldBridge ) {
+ idBridge = (IdFieldBridge) fieldBridge;
+ }
+ else {
+ throw new HibernateException(
+ "Bridge for document id does not implement IdFieldBridge: " + member.getName() );
+ }
+ }
+ else {
+ setAccessible( member );
+ keywordGetters.add( member );
+ keywordNames.add( name );
+ keywordBridges.add( BridgeFactory.guessType( member ) );
+ }
+ }
+
+ Unstored unstoredAnn = member.getAnnotation( Unstored.class );
+ if ( unstoredAnn != null ) {
+ setAccessible( member );
+ unstoredGetters.add( member );
+ unstoredNames.add( BinderHelper.getAttributeName( member, unstoredAnn.name() ) );
+ unstoredBridges.add( BridgeFactory.guessType( member ) );
+ }
+
+ Text textAnn = member.getAnnotation( Text.class );
+ if ( textAnn != null ) {
+ setAccessible( member );
+ textGetters.add( member );
+ textNames.add( BinderHelper.getAttributeName( member, textAnn.name() ) );
+ textBridges.add( BridgeFactory.guessType( member ) );
+ }
+
+ DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
+ if ( documentIdAnn != null ) {
+ if ( idKeywordName != null ) {
+ throw new AssertionFailure( "Two document id assigned: "
+ + idKeywordName + " and " + BinderHelper.getAttributeName( member, documentIdAnn.name() ) );
+ }
+ idKeywordName = BinderHelper.getAttributeName( member, documentIdAnn.name() );
+ FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ if ( fieldBridge instanceof IdFieldBridge ) {
+ idBridge = (IdFieldBridge) fieldBridge;
+ }
+ else {
+ throw new HibernateException(
+ "Bridge for document id does not implement IdFieldBridge: " + member.getName() );
+ }
+ idBoost = getBoost( member );
+ }
+
+ org.hibernate.lucene.annotations.Field fieldAnn =
+ member.getAnnotation( org.hibernate.lucene.annotations.Field.class );
+ if ( fieldAnn != null ) {
+ setAccessible( member );
+ fieldGetters.add( member );
+ fieldNames.add( BinderHelper.getAttributeName( member, fieldAnn.name() ) );
+ fieldStore.add( getStore( fieldAnn.store() ) );
+ fieldIndex.add( getIndex( fieldAnn.index() ) );
+ fieldBridges.add( BridgeFactory.guessType( member ) );
+ }
+ }
+
+ private Field.Store getStore(Store store) {
+ switch (store) {
+ case NO:
+ return Field.Store.NO;
+ case YES:
+ return Field.Store.YES;
+ case COMPRESS:
+ return Field.Store.COMPRESS;
+ default:
+ throw new AssertionFailure( "Unexpected Store: " + store );
+ }
+ }
+
+ private Field.Index getIndex(Index index) {
+ switch (index) {
+ case NO:
+ return Field.Index.NO;
+ case NO_NORMS:
+ return Field.Index.NO_NORMS;
+ case TOKENIZED:
+ return Field.Index.TOKENIZED;
+ case UN_TOKENISED:
+ return Field.Index.UN_TOKENIZED;
+ default:
+ throw new AssertionFailure( "Unexpected Index: " + index );
+ }
+ }
+
+ private Float getBoost(XAnnotatedElement element) {
+ if ( element == null ) return null;
+ Boost boost = element.getAnnotation( Boost.class );
+ return boost != null ?
+ boost.value() :
+ null;
+ }
+
+ private Object getMemberValue(T bean, XMember getter) {
+ Object value;
+ try {
+ value = getter.invoke( bean );
+ }
+ catch (Exception e) {
+ throw new IllegalStateException( "Could not get property value", e );
+ }
+ return value;
+ }
+
+ public Document getDocument(T instance, Serializable id) {
+ Document doc = new Document();
+ XClass instanceClass = reflectionManager.toXClass( instance.getClass() );
+ Float boost = getBoost( instanceClass );
+ if ( boost != null ) {
+ doc.setBoost( boost );
+ }
+ {
+ Field classField =
+ new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED );
+ doc.add( classField );
+ idBridge.set( idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, idBoost );
+ }
+ for ( int i = 0; i < keywordNames.size(); i++ ) {
+ XMember member = keywordGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ keywordBridges.get( i ).set(
+ keywordNames.get( i ), value, doc, Field.Store.YES,
+ Field.Index.UN_TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < textNames.size(); i++ ) {
+ XMember member = textGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ textBridges.get( i ).set(
+ textNames.get( i ), value, doc, Field.Store.YES,
+ Field.Index.TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < unstoredNames.size(); i++ ) {
+ XMember member = unstoredGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ unstoredBridges.get( i ).set(
+ unstoredNames.get( i ), value, doc, Field.Store.NO,
+ Field.Index.TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < fieldNames.size(); i++ ) {
+ XMember member = fieldGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ fieldBridges.get( i ).set(
+ fieldNames.get( i ), value, doc, fieldStore.get( i ),
+ fieldIndex.get( i ), getBoost( member )
+ );
+ }
+ return doc;
+ }
+
+ public Term getTerm(Serializable id) {
+ return new Term( idKeywordName, idBridge.objectToString( id ) );
+ }
+
+ public DirectoryProvider getDirectoryProvider() {
+ return directoryProvider;
+ }
+
+ public Analyzer getAnalyzer() {
+ return analyzer;
+ }
+
+ private static void setAccessible(XMember member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ member.setAccessible( true );
+ }
+ }
+
+ public IdFieldBridge getIdBridge() {
+ return idBridge;
+ }
+
+ public String getIdKeywordName() {
+ return idKeywordName;
+ }
+
+ public static Class getDocumentClass(Document document) {
+ String className = document.get( DocumentBuilder.CLASS_FIELDNAME );
+ try {
+ return ReflectHelper.classForName( className );
+ }
+ catch (ClassNotFoundException e) {
+ throw new HibernateException( "Unable to load indexed class: " + className, e );
+ }
+ }
+
+ public static Serializable getDocumentId(LuceneEventListener listener, Class clazz, Document document) {
+ DocumentBuilder builder = listener.getDocumentBuilders().get( clazz );
+ if ( builder == null ) throw new HibernateException( "No Lucene configuration set up for: " + clazz.getName() );
+ return (Serializable) builder.getIdBridge().get( builder.getIdKeywordName(), document );
+ }
+
+ public void postInitialize(Set<Class> indexedClasses) {
+ //this method does not requires synchronization
+ Class plainClass = reflectionManager.toClass( beanClass );
+ Set<Class> tempMappedSubclasses = new HashSet<Class>();
+ //together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
+ for ( Class currentClass : indexedClasses ) {
+ if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add( currentClass );
+ }
+ mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
+ }
+
+
+ public Set<Class> getMappedSubclasses() {
+ return mappedSubclasses;
+ }
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,15 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public class AddWork extends Work {
- public AddWork(Serializable id, Class entity, Document document) {
- super( id, entity, document );
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,13 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-/**
- * @author Emmanuel Bernard
- */
-public class DeleteWork extends Work {
- public DeleteWork(Serializable id, Class entity) {
- super( id, entity );
- }
-}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,13 +1,11 @@
//$Id$
package org.hibernate.lucene.event;
-import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.transaction.Status;
@@ -16,9 +14,6 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
@@ -30,9 +25,16 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEvent;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.DocumentBuilder;
import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.backend.AddWork;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.Work;
+import org.hibernate.lucene.backend.WorkQueue;
+import org.hibernate.lucene.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.lucene.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.store.DirectoryProvider;
import org.hibernate.lucene.store.DirectoryProviderFactory;
import org.hibernate.mapping.PersistentClass;
@@ -161,9 +163,9 @@
}
private void processWork(Work work, AbstractEvent event) {
- WorkQueue workQueue = new WorkQueue( documentBuilders, lockableDirectoryProviders );
+ WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders, lockableDirectoryProviders );
workQueue.add( work );
- WorkInSynchronization sync = new WorkInSynchronization( workQueue );
+ PostTransactionWorkQueueSynchronization sync = new PostTransactionWorkQueueSynchronization( workQueue );
if ( event.getSession().isTransactionInProgress() ) {
event.getSession().getTransaction().registerSynchronization( sync );
}
@@ -171,51 +173,4 @@
sync.afterCompletion( Status.STATUS_COMMITTED );
}
}
-
- @Deprecated
- private void remove(DocumentBuilder<?> builder, Serializable id) {
- //FIXME lookup by term id and filter by test _hibernate_class
- Term term = builder.getTerm( id );
- log.debug( "removing: " + term );
- DirectoryProvider directoryProvider = builder.getDirectoryProvider();
- Lock lock = lockableDirectoryProviders.get( directoryProvider );
- lock.lock();
- try {
-
- IndexReader reader = IndexReader.open( directoryProvider.getDirectory() );
- reader.deleteDocuments( term );
- reader.close();
- }
- catch (IOException ioe) {
- throw new HibernateException( ioe );
- }
- finally {
- lock.unlock();
- }
- }
-
- @Deprecated
- private void add(final Object entity, final DocumentBuilder<Object> builder, final Serializable id) {
- Document doc = builder.getDocument( entity, id );
- if ( log.isDebugEnabled() ) {
- log.debug( "adding: " + doc );
- }
- DirectoryProvider directoryProvider = builder.getDirectoryProvider();
- Lock lock = lockableDirectoryProviders.get( directoryProvider );
- lock.lock();
- try {
- IndexWriter writer = new IndexWriter(
- directoryProvider.getDirectory(), builder.getAnalyzer(), false
- ); //have been created at init time
- writer.addDocument( doc );
- writer.close();
- }
- catch (IOException ioe) {
- throw new HibernateException( ioe );
- }
- finally {
- lock.unlock();
- }
- }
-
}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,15 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public class UpdateWork extends Work {
- public UpdateWork(Serializable id, Class entity, Document document) {
- super( id, entity, document );
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,40 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * Represent a Lucene unit work
- *
- * @author Emmanuel Bernard
- */
-public abstract class Work implements Serializable {
- private Document document;
- private Class entity;
- private Serializable id;
-
- public Work(Serializable id, Class entity) {
- this( id, entity, null );
- }
-
- public Work(Serializable id, Class entity, Document document) {
- this.id = id;
- this.entity = entity;
- this.document = document;
- }
-
-
- public Document getDocument() {
- return document;
- }
-
- public Class getEntity() {
- return entity;
- }
-
- public Serializable getId() {
- return id;
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,34 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-/**
- * Execute some work inside a transaction sychronization
- *
- * @author Emmanuel Bernard
- */
-public class WorkInSynchronization implements Synchronization {
- private WorkQueue workQueue;
-
- public WorkInSynchronization(WorkQueue workQueue) {
- this.workQueue = workQueue;
- }
-
- public void beforeCompletion() {
- }
-
- public void afterCompletion(int i) {
- if ( Status.STATUS_COMMITTED == i ) {
- workQueue.performWork();
- }
- else {
- workQueue.cancelWork();
- }
- }
-
- public static interface Work {
- void perform();
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,58 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.hibernate.lucene.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-
-/**
- * @author Emmanuel Bernard
- */
-public class WorkQueue {
- private Workspace workspace;
- private Worker worker;
- private List<Work> queue = new ArrayList<Work>();
-
- public WorkQueue(Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- workspace = new Workspace( documentBuilders, lockableDirectoryProviders );
- worker = new Worker( workspace );
- }
-
- public void add(Work work) {
- //TODO optimize by getting rid of dupe works
- if ( work instanceof UpdateWork ) {
- //split in 2 to optimize the process (reader first, writer next
- queue.add( new DeleteWork( work.getId(), work.getEntity() ) );
- queue.add( new AddWork( work.getId(), work.getEntity(), work.getDocument() ) );
- }
- else {
- queue.add( work );
- }
- }
-
- public void performWork() {
- try {
- //use of index reader
- for ( Work work : queue ) {
- if ( work instanceof DeleteWork ) worker.performWork( work );
- }
- workspace.clean(); //close readers
- for ( Work work : queue ) {
- if ( work instanceof AddWork ) worker.performWork( work );
- }
- }
- finally {
- workspace.clean();
- queue.clear();
- }
- }
-
- public void cancelWork() {
- queue.clear();
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,111 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermDocs;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.lucene.DocumentBuilder;
-
-/**
- * Stateless implementation that perform a work
- *
- * @author Emmanuel Bernard
- */
-public class Worker {
- private Workspace workspace;
- private static Log log = LogFactory.getLog( Worker.class );
-
- public Worker(Workspace workspace) {
- this.workspace = workspace;
- }
-
- public void performWork(Work work) {
- if ( AddWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (AddWork) work );
- }
- else if ( UpdateWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (UpdateWork) work );
- }
- else if ( DeleteWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (DeleteWork) work );
- }
- else {
- throw new AssertionFailure( "Unknown work type: " + work.getClass() );
- }
- }
-
- public void performWork(AddWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- Document document = work.getDocument();
- add( entity, id, document );
- }
-
- private void add(Class entity, Serializable id, Document document) {
- if ( log.isTraceEnabled() )
- log.trace( "add to Lucene index: " + entity + "#" + id + ": " + document );
- IndexWriter writer = workspace.getIndexWriter( entity );
- try {
- writer.addDocument( document );
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to add to Lucene index: " + entity + "#" + id, e );
- }
- }
-
- public void performWork(UpdateWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- Document document = work.getDocument();
- remove( entity, id );
- add( entity, id, document );
- }
-
- public void performWork(DeleteWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- remove( entity, id );
- }
-
- private void remove(Class entity, Serializable id) {
- log.trace( "remove from Lucene index: " + entity + "#" + id );
- DocumentBuilder builder = workspace.getDocumentBuilder( entity );
- Term term = builder.getTerm( id );
- IndexReader reader = workspace.getIndexReader( entity );
- TermDocs termDocs = null;
- try {
- //TODO is there a faster way?
- //TODO include TermDocs into the workspace?
- termDocs = reader.termDocs( term );
- String entityName = entity.getName();
- while ( termDocs.next() ) {
- int docIndex = termDocs.doc();
- if ( entityName.equals( reader.document( docIndex ).get( DocumentBuilder.CLASS_FIELDNAME ) ) ) {
- //remove only the one of the right class
- //loop all to remove all the matches (defensive code)
- reader.deleteDocument( docIndex );
- }
- }
- }
- catch (Exception e) {
- throw new HibernateException( "Unable to remove from Lucene index: " + entity + "#" + id, e );
- }
- finally {
- if (termDocs != null) try {
- termDocs.close();
- }
- catch (IOException e) {
- log.warn( "Unable to close termDocs properly", e);
- }
- }
- }
-}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,137 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.hibernate.HibernateException;
-import org.hibernate.lucene.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-
-/**
- * Lucene workspace
- * This is not intended to be used in a multithreaded environment
- * <p/>
- * One cannot execute modification through an IndexReader when an IndexWriter has been acquired on the same underlying directory
- * One cannot get an IndexWriter when an IndexReader have been acquired and modificed on the same underlying directory
- * The recommended approach is to execute all the modifications on the IndexReaders, {@link #clean()} }, and acquire the
- * index writers
- *
- * @author Emmanuel Bernard
- */
-//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene use abstract classes, not interfaces
-public class Workspace {
- private static Log log = LogFactory.getLog( Workspace.class );
- private Map<Class, DocumentBuilder<Object>> documentBuilders;
- private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders;
- private Map<DirectoryProvider, IndexReader> readers = new HashMap<DirectoryProvider, IndexReader>();
- private Map<DirectoryProvider, IndexWriter> writers = new HashMap<DirectoryProvider, IndexWriter>();
- private List<DirectoryProvider> lockedProviders = new ArrayList<DirectoryProvider>();
-
- public Workspace(Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- this.documentBuilders = documentBuilders;
- this.lockableDirectoryProviders = lockableDirectoryProviders;
- }
-
-
- public DocumentBuilder getDocumentBuilder(Class entity) {
- return documentBuilders.get( entity );
- }
-
- public IndexReader getIndexReader(Class entity) {
- //TODO NPEs
- DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
- IndexReader reader = readers.get( provider );
- if ( reader != null ) return reader;
- lockProvider( provider );
- try {
- reader = IndexReader.open( provider.getDirectory() );
- readers.put( provider, reader );
- }
- catch (IOException e) {
- cleanUp( new HibernateException( "Unable to open IndexReader for " + entity, e ) );
- }
- return reader;
- }
-
- public IndexWriter getIndexWriter(Class entity) {
- DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
- IndexWriter writer = writers.get( provider );
- if ( writer != null ) return writer;
- lockProvider( provider );
- try {
- writer = new IndexWriter(
- provider.getDirectory(), documentBuilders.get( entity ).getAnalyzer(), false
- ); //have been created at init time
- writers.put( provider, writer );
- }
- catch (IOException e) {
- cleanUp( new HibernateException( "Unable to open IndexWriter for " + entity, e ) );
- }
- return writer;
- }
-
- private void lockProvider(DirectoryProvider provider) {
- //make sure to use a semaphore
- ReentrantLock lock = lockableDirectoryProviders.get( provider );
- //of course a given thread cannot have a race cond with itself
- if ( !lock.isHeldByCurrentThread() ) {
- lock.lock();
- lockedProviders.add( provider );
- }
- }
-
- private void cleanUp(HibernateException originalException) {
- //release all readers and writers, then reelase locks
- HibernateException raisedException = originalException;
- for ( IndexReader reader : readers.values() ) {
- try {
- reader.close();
- }
- catch (IOException e) {
- if ( raisedException != null ) {
- log.error( "Subsequent Exception while closing IndexReader", e );
- }
- else {
- raisedException = new HibernateException( "Exception while closing IndexReader", e );
- }
- }
- }
- for ( IndexWriter writer : writers.values() ) {
- try {
- writer.close();
- }
- catch (IOException e) {
- if ( raisedException != null ) {
- log.error( "Subsequent Exception while closing IndexWriter", e );
- }
- else {
- raisedException = new HibernateException( "Exception while closing IndexWriter", e );
- }
- }
- }
- for ( DirectoryProvider provider : lockedProviders ) {
- lockableDirectoryProviders.get( provider ).unlock();
- }
- readers.clear();
- writers.clear();
- lockedProviders.clear();
- if ( raisedException != null ) throw raisedException;
- }
-
- /**
- * release resources consumed in the workspace if any
- */
- public void clean() {
- cleanUp( null );
- }
-}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -27,7 +27,7 @@
}
public Object next() {
- Object object = session.get( entityInfos.get(index).clazz, entityInfos.get(index).id );
+ Object object = session.get( entityInfos.get( index ).clazz, entityInfos.get( index ).id );
index++;
return object;
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -14,15 +14,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiSearcher;
import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.index.Term;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
@@ -34,7 +34,7 @@
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.impl.AbstractQueryImpl;
-import org.hibernate.lucene.DocumentBuilder;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.event.LuceneEventListener;
/**
@@ -76,18 +76,18 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
hits = searcher.search( query );
setResultSize( hits );
int first = first();
int max = max( first, hits );
- List<EntityInfo> entityInfos = new ArrayList<EntityInfo>(max - first + 1);
+ List<EntityInfo> entityInfos = new ArrayList<EntityInfo>( max - first + 1 );
for ( int index = first; index <= max; index++ ) {
Document document = hits.doc( index );
EntityInfo entityInfo = new EntityInfo();
entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document );
- entityInfos.add(entityInfo);
+ entityInfos.add( entityInfo );
}
return new IteratorImpl( entityInfos, (Session) this.session );
}
@@ -140,8 +140,8 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
- log.warn(query.toString());
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ log.warn( query.toString() );
hits = searcher.search( query );
setResultSize( hits );
int first = first();
@@ -178,14 +178,14 @@
private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
//A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
//it also probably minimise the memory footprint
- if (classesAndSubclasses == null) {
+ if ( classesAndSubclasses == null ) {
return luceneQuery;
}
else {
BooleanQuery classFilter = new BooleanQuery();
//annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
classFilter.setBoost( 0 );
- for (Class clazz : classesAndSubclasses) {
+ for ( Class clazz : classesAndSubclasses ) {
Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
TermQuery termQuery = new TermQuery( t );
classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -17,7 +17,7 @@
import org.hibernate.HibernateException;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
-import org.hibernate.lucene.DocumentBuilder;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.event.LuceneEventListener;
import org.hibernate.type.Type;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -17,7 +17,9 @@
* @author Sylvain Vieujot
*/
public interface DirectoryProvider<TDirectory extends Directory> {
- /** get the information to initialize the directory and build its hashCode */
+ /**
+ * get the information to initialize the directory and build its hashCode
+ */
void initialize(String directoryProviderName, Properties properties);
/**
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -7,12 +7,12 @@
import java.util.Properties;
import org.hibernate.HibernateException;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.reflection.ReflectionManager;
import org.hibernate.reflection.XClass;
-import org.hibernate.reflection.ReflectionManager;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.lucene.Indexed;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
@@ -20,14 +20,14 @@
* Create a Lucene directory provider
* <p/>
* Lucene directory providers are configured through properties
- * - hibernate.lucene.default.* and
- * - hibernate.lucene.<indexname>.*
- *
+ * - hibernate.lucene.default.* and
+ * - hibernate.lucene.<indexname>.*
+ * <p/>
* <indexname> properties have precedence over default
- *
+ * <p/>
* The implementation is described by
* hibernate.lucene.[default|indexname].directory_provider
- *
+ * <p/>
* If none is defined the default value is FSDirectory
*
* @author Emmanuel Bernard
@@ -39,10 +39,10 @@
private static String LUCENE_DEFAULT = LUCENE_PREFIX + "default.";
private static String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
- //TODO for the public?
- //public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration cfg) {
+ //TODO for the public?
+ //public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration cfg) {
- public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration cfg) {
+ public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration cfg) {
//get properties
String directoryProviderName = getDirectoryProviderName( entity, cfg );
Properties indexProps = getDirectoryProperties( cfg, directoryProviderName );
@@ -54,8 +54,8 @@
}
DirectoryProvider<?> provider = null;
try {
- @SuppressWarnings("unchecked")
- Class<DirectoryProvider> directoryClass = ReflectHelper.classForName(
+ @SuppressWarnings( "unchecked" )
+ Class<DirectoryProvider> directoryClass = ReflectHelper.classForName(
className, DirectoryProviderFactory.class
);
provider = directoryClass.newInstance();
@@ -94,10 +94,10 @@
}
public static String getDirectoryProviderName(XClass clazz, Configuration cfg) {
- //yuk
- ReflectionManager reflectionManager =
- ( (AnnotationConfiguration) cfg ).createExtendedMappings().getReflectionManager();
- //get the most specialized (ie subclass > superclass) non default index name
+ //yuk
+ ReflectionManager reflectionManager =
+ ( (AnnotationConfiguration) cfg ).createExtendedMappings().getReflectionManager();
+ //get the most specialized (ie subclass > superclass) non default index name
//if none extract the name from the most generic (superclass > subclass) @Indexed class in the hierarchy
//FIXME I'm inclined to get rid of the default value
PersistentClass pc = cfg.getClassMapping( clazz.getName() );
@@ -105,7 +105,7 @@
do {
XClass currentClazz = reflectionManager.toXClass( pc.getMappedClass() );
Indexed indexAnn = currentClazz.getAnnotation( Indexed.class );
- if (indexAnn != null) {
+ if ( indexAnn != null ) {
if ( indexAnn.index().length() != 0 ) {
return indexAnn.index();
}
@@ -113,14 +113,16 @@
rootIndex = currentClazz;
}
}
- pc = pc.getSuperclass();
- } while (pc != null);
+ pc = pc.getSuperclass();
+ }
+ while ( pc != null );
//there is nobody outthere with a non default @Indexed.index
- if (rootIndex != null) {
+ if ( rootIndex != null ) {
return rootIndex.getName();
}
else {
- throw new HibernateException("Trying to extract the index name from a non @Indexed class: " + clazz.getName() );
+ throw new HibernateException(
+ "Trying to extract the index name from a non @Indexed class: " + clazz.getName() );
}
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -45,8 +45,8 @@
boolean create = !file.exists();
indexName = file.getCanonicalPath();
directory = FSDirectory.getDirectory( indexName, create );
- if (create) {
- IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), create );
+ if ( create ) {
+ IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), create );
iw.close();
}
}
@@ -65,9 +65,9 @@
// this code is actually broken since the value change after initialize call
// but from a practical POV this is fine since we only call this method
// after initialize call
- if (obj == this) return true;
- if (obj == null || ! (obj instanceof FSDirectoryProvider) ) return false;
- return indexName.equals( ( (FSDirectoryProvider) obj).indexName );
+ if ( obj == this ) return true;
+ if ( obj == null || !( obj instanceof FSDirectoryProvider ) ) return false;
+ return indexName.equals( ( (FSDirectoryProvider) obj ).indexName );
}
@Override
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -24,7 +24,7 @@
indexName = directoryProviderName;
directory = new RAMDirectory();
try {
- IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), true );
+ IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), true );
iw.close();
}
catch (IOException e) {
@@ -41,9 +41,9 @@
// this code is actually broken since the value change after initialize call
// but from a practical POV this is fine since we only call this method
// after initialize call
- if (obj == this) return true;
- if (obj == null || ! (obj instanceof RAMDirectoryProvider) ) return false;
- return indexName.equals( ( (RAMDirectoryProvider) obj).indexName );
+ if ( obj == this ) return true;
+ if ( obj == null || !( obj instanceof RAMDirectoryProvider ) ) return false;
+ return indexName.equals( ( (RAMDirectoryProvider) obj ).indexName );
}
@Override
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,27 +1,23 @@
//$Id: $
package org.hibernate.lucene.util;
-import java.lang.reflect.Method;
-import java.lang.reflect.Member;
-import java.lang.reflect.Field;
-import java.beans.Introspector;
-
-import org.hibernate.util.StringHelper;
import org.hibernate.reflection.XMember;
+import org.hibernate.util.StringHelper;
/**
* @author Emmanuel Bernard
*/
public abstract class BinderHelper {
- private BinderHelper() {}
+ private BinderHelper() {
+ }
/**
* Get attribute name out of member unless overriden by <code>name</code>
*/
public static String getAttributeName(XMember member, String name) {
return StringHelper.isNotEmpty( name ) ?
- name :
- member.getName(); //explicit field name
+ name :
+ member.getName(); //explicit field name
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -3,15 +3,14 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
import javax.persistence.Lob;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Store;
-import org.hibernate.lucene.Index;
-import org.hibernate.lucene.Boost;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Store;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.Boost;
/**
* Example of 2 entities mapped in the same index
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -4,9 +4,9 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -6,15 +6,12 @@
import javax.persistence.Id;
import javax.persistence.Lob;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Unstored;
-import org.hibernate.lucene.Boost;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Index;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Store;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Store;
@Entity
@Indexed(index = "Documents")
@@ -38,7 +35,7 @@
@GeneratedValue
//@Keyword(id = true)
@DocumentId
- public Long getId() {
+ public Long getId() {
return id;
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -6,11 +6,11 @@
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.DateBridge;
-import org.hibernate.lucene.FieldBridge;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.DateBridge;
+import org.hibernate.lucene.annotations.FieldBridge;
import org.hibernate.lucene.bridge.Resolution;
import org.hibernate.annotations.Parameter;
@@ -143,7 +143,7 @@
}
@Text
- public String getString() {
+ public String getString() {
return string;
}
@@ -222,7 +222,7 @@
}
@Keyword
- @DateBridge( Resolution.MILLISECOND )
+ @DateBridge( Resolution.MILLISECOND )
public Date getDateMillisecond() {
return dateMillisecond;
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -6,11 +6,11 @@
import javax.persistence.Entity;
import javax.persistence.Lob;
-import org.hibernate.lucene.Unstored;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Boost;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Unstored;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.Indexed;
/**
* @author Richard Hallier
@@ -24,7 +24,7 @@
private Long id;
@Text
- @Boost(2)
+ @Boost(2)
private String title;
@Unstored(name = "Abstract")
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,9 +1,9 @@
//$Id: $
package org.hibernate.lucene.test.inheritance;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Indexed;
import javax.persistence.Entity;
import javax.persistence.Id;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -1,9 +1,8 @@
//$Id: $
package org.hibernate.lucene.test.inheritance;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Keyword;
import javax.persistence.Entity;
@@ -16,7 +15,7 @@
private int mammalNbr;
@Keyword
- public int getMammalNbr() {
+ public int getMammalNbr() {
return mammalNbr;
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -4,10 +4,10 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Index;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Index;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -4,10 +4,10 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Unstored;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Unstored;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java 2006-11-01 22:53:30 UTC (rev 10680)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java 2006-11-01 23:06:05 UTC (rev 10681)
@@ -4,9 +4,9 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
/**
* @author Emmanuel Bernard
18 years, 2 months
Hibernate SVN: r10680 - in trunk/Hibernate3/src/org/hibernate: action event
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 17:53:30 -0500 (Wed, 01 Nov 2006)
New Revision: 10680
Modified:
trunk/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java
trunk/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java
trunk/Hibernate3/src/org/hibernate/action/EntityInsertAction.java
trunk/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java
trunk/Hibernate3/src/org/hibernate/event/PostInsertEvent.java
Log:
HHH-2203 make Post*Event extends AbstractEvent
Modified: trunk/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java 2006-11-01 22:53:04 UTC (rev 10679)
+++ trunk/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java 2006-11-01 22:53:30 UTC (rev 10680)
@@ -15,6 +15,7 @@
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PreDeleteEvent;
import org.hibernate.event.PreDeleteEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityDeleteAction extends EntityAction {
@@ -115,7 +116,13 @@
PostDeleteEventListener[] postListeners = getSession().getListeners()
.getPostDeleteEventListeners();
if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent( getInstance(), getId(), state, getPersister() );
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostDelete(postEvent);
}
@@ -126,7 +133,13 @@
PostDeleteEventListener[] postListeners = getSession().getListeners()
.getPostCommitDeleteEventListeners();
if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent( getInstance(), getId(), state, getPersister() );
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostDelete(postEvent);
}
Modified: trunk/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java 2006-11-01 22:53:04 UTC (rev 10679)
+++ trunk/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java 2006-11-01 22:53:30 UTC (rev 10680)
@@ -11,6 +11,7 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PreInsertEvent;
import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityIdentityInsertAction extends EntityAction {
@@ -78,7 +79,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostInsertEventListeners();
if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), generatedId, state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
@@ -89,7 +96,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostCommitInsertEventListeners();
if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), generatedId, state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
Modified: trunk/Hibernate3/src/org/hibernate/action/EntityInsertAction.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/action/EntityInsertAction.java 2006-11-01 22:53:04 UTC (rev 10679)
+++ trunk/Hibernate3/src/org/hibernate/action/EntityInsertAction.java 2006-11-01 22:53:30 UTC (rev 10680)
@@ -15,6 +15,7 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PreInsertEvent;
import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityInsertAction extends EntityAction {
@@ -111,7 +112,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostInsertEventListeners();
if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), getId(), state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
@@ -122,7 +129,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostCommitInsertEventListeners();
if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), getId(), state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
Modified: trunk/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java 2006-11-01 22:53:04 UTC (rev 10679)
+++ trunk/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java 2006-11-01 22:53:30 UTC (rev 10680)
@@ -10,7 +10,7 @@
*
* @author Gavin King
*/
-public class PostDeleteEvent {
+public class PostDeleteEvent extends AbstractEvent {
private Object entity;
private EntityPersister persister;
private Serializable id;
@@ -20,8 +20,10 @@
Object entity,
Serializable id,
Object[] deletedState,
- EntityPersister persister
+ EntityPersister persister,
+ EventSource source
) {
+ super(source);
this.entity = entity;
this.id = id;
this.persister = persister;
Modified: trunk/Hibernate3/src/org/hibernate/event/PostInsertEvent.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/event/PostInsertEvent.java 2006-11-01 22:53:04 UTC (rev 10679)
+++ trunk/Hibernate3/src/org/hibernate/event/PostInsertEvent.java 2006-11-01 22:53:30 UTC (rev 10680)
@@ -10,7 +10,7 @@
*
* @author Gavin King
*/
-public class PostInsertEvent {
+public class PostInsertEvent extends AbstractEvent {
private Object entity;
private EntityPersister persister;
private Object[] state;
@@ -20,8 +20,10 @@
Object entity,
Serializable id,
Object[] state,
- EntityPersister persister
+ EntityPersister persister,
+ EventSource source
) {
+ super(source);
this.entity = entity;
this.id = id;
this.state = state;
18 years, 2 months
Hibernate SVN: r10679 - in branches/Branch_3_2/Hibernate3/src/org/hibernate: action event
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 17:53:04 -0500 (Wed, 01 Nov 2006)
New Revision: 10679
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityInsertAction.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostInsertEvent.java
Log:
HHH-2203 make Post*Event extends AbstractEvent
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityDeleteAction.java 2006-11-01 22:53:04 UTC (rev 10679)
@@ -15,6 +15,7 @@
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PreDeleteEvent;
import org.hibernate.event.PreDeleteEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityDeleteAction extends EntityAction {
@@ -115,7 +116,13 @@
PostDeleteEventListener[] postListeners = getSession().getListeners()
.getPostDeleteEventListeners();
if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent( getInstance(), getId(), state, getPersister() );
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostDelete(postEvent);
}
@@ -126,7 +133,13 @@
PostDeleteEventListener[] postListeners = getSession().getListeners()
.getPostCommitDeleteEventListeners();
if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent( getInstance(), getId(), state, getPersister() );
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostDelete(postEvent);
}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityIdentityInsertAction.java 2006-11-01 22:53:04 UTC (rev 10679)
@@ -11,6 +11,7 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PreInsertEvent;
import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityIdentityInsertAction extends EntityAction {
@@ -78,7 +79,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostInsertEventListeners();
if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), generatedId, state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
@@ -89,7 +96,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostCommitInsertEventListeners();
if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), generatedId, state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityInsertAction.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityInsertAction.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityInsertAction.java 2006-11-01 22:53:04 UTC (rev 10679)
@@ -15,6 +15,7 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PreInsertEvent;
import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
public final class EntityInsertAction extends EntityAction {
@@ -111,7 +112,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostInsertEventListeners();
if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), getId(), state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
@@ -122,7 +129,13 @@
PostInsertEventListener[] postListeners = getSession().getListeners()
.getPostCommitInsertEventListeners();
if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent( getInstance(), getId(), state, getPersister() );
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent);
}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostDeleteEvent.java 2006-11-01 22:53:04 UTC (rev 10679)
@@ -10,7 +10,7 @@
*
* @author Gavin King
*/
-public class PostDeleteEvent {
+public class PostDeleteEvent extends AbstractEvent {
private Object entity;
private EntityPersister persister;
private Serializable id;
@@ -20,8 +20,10 @@
Object entity,
Serializable id,
Object[] deletedState,
- EntityPersister persister
+ EntityPersister persister,
+ EventSource source
) {
+ super(source);
this.entity = entity;
this.id = id;
this.persister = persister;
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostInsertEvent.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostInsertEvent.java 2006-11-01 21:32:11 UTC (rev 10678)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/event/PostInsertEvent.java 2006-11-01 22:53:04 UTC (rev 10679)
@@ -10,7 +10,7 @@
*
* @author Gavin King
*/
-public class PostInsertEvent {
+public class PostInsertEvent extends AbstractEvent {
private Object entity;
private EntityPersister persister;
private Object[] state;
@@ -20,8 +20,10 @@
Object entity,
Serializable id,
Object[] state,
- EntityPersister persister
+ EntityPersister persister,
+ EventSource source
) {
+ super(source);
this.entity = entity;
this.id = id;
this.state = state;
18 years, 2 months
Hibernate SVN: r10678 - in branches/Lucene_Integration/HibernateExt/metadata/src: java/org/hibernate/lucene java/org/hibernate/lucene/query test/org/hibernate/lucene/test/query
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 16:32:11 -0500 (Wed, 01 Nov 2006)
New Revision: 10678
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java
Log:
ANN-460 filter by classes on queries
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01 19:07:24 UTC (rev 10677)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01 21:32:11 UTC (rev 10678)
@@ -219,7 +219,7 @@
}
{
Field classField =
- new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.NO );
+ new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED );
doc.add( classField );
idBridge.set( idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, idBoost );
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01 19:07:24 UTC (rev 10677)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01 21:32:11 UTC (rev 10678)
@@ -2,6 +2,7 @@
package org.hibernate.lucene.query;
import java.util.Iterator;
+import java.util.List;
import org.hibernate.Session;
@@ -10,15 +11,15 @@
*/
public class IteratorImpl implements Iterator {
- private final EntityInfo[] entityInfos;
+ private final List<EntityInfo> entityInfos;
private final Session session;
private int index = 0;
private final int size;
- public IteratorImpl(EntityInfo[] entityInfos, Session session) {
+ public IteratorImpl(List<EntityInfo> entityInfos, Session session) {
this.entityInfos = entityInfos;
this.session = session;
- this.size = entityInfos.length;
+ this.size = entityInfos.size();
}
public boolean hasNext() {
@@ -26,13 +27,13 @@
}
public Object next() {
- Object object = session.get( entityInfos[index].clazz, entityInfos[index].id );
+ Object object = session.get( entityInfos.get(index).clazz, entityInfos.get(index).id );
index++;
return object;
}
public void remove() {
//TODO this is theorically doable
- throw new UnsupportedOperationException( "Cannot remove from a lucene query interator" );
+ throw new UnsupportedOperationException( "Cannot remove from a lucene query iterator" );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 19:07:24 UTC (rev 10677)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 21:32:11 UTC (rev 10678)
@@ -18,7 +18,11 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiSearcher;
import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.index.Term;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
@@ -41,6 +45,7 @@
private static final Log log = LogFactory.getLog( LuceneQueryImpl.class );
private org.apache.lucene.search.Query luceneQuery;
private Class[] classes;
+ private Set<Class> classesAndSubclasses;
private Integer firstResult;
private Integer maxResults;
private int resultSize;
@@ -71,18 +76,18 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- hits = searcher.search( luceneQuery );
+ org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
+ hits = searcher.search( query );
setResultSize( hits );
int first = first();
int max = max( first, hits );
- EntityInfo[] entityInfos = new EntityInfo[max - first + 1];
+ List<EntityInfo> entityInfos = new ArrayList<EntityInfo>(max - first + 1);
for ( int index = first; index <= max; index++ ) {
Document document = hits.doc( index );
EntityInfo entityInfo = new EntityInfo();
entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
- //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document );
- entityInfos[index - first] = entityInfo;
+ entityInfos.add(entityInfo);
}
return new IteratorImpl( entityInfos, (Session) this.session );
}
@@ -106,7 +111,8 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- hits = searcher.search( luceneQuery );
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ hits = searcher.search( query );
setResultSize( hits );
int first = first();
int max = max( first, hits );
@@ -134,7 +140,9 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- hits = searcher.search( luceneQuery );
+ org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
+ log.warn(query.toString());
+ hits = searcher.search( query );
setResultSize( hits );
int first = first();
int max = max( first, hits );
@@ -143,10 +151,10 @@
for ( int index = first; index <= max; index++ ) {
Document document = hits.doc( index );
Class clazz = DocumentBuilder.getDocumentClass( document );
- //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
Serializable id = DocumentBuilder.getDocumentId( listener, clazz, document );
result.add( sess.load( clazz, id ) );
- //use load to benefit from the batch-size (but facing some proxy casting issues...
+ //use load to benefit from the batch-size
+ //we don't face proxy casting issues since the exact class is extracted from the index
}
//then initialize the objects
for ( Object element : result ) {
@@ -167,11 +175,33 @@
}
}
+ private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
+ //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
+ //it also probably minimise the memory footprint
+ if (classesAndSubclasses == null) {
+ return luceneQuery;
+ }
+ else {
+ BooleanQuery classFilter = new BooleanQuery();
+ //annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
+ classFilter.setBoost( 0 );
+ for (Class clazz : classesAndSubclasses) {
+ Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
+ TermQuery termQuery = new TermQuery( t );
+ classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
+ }
+ BooleanQuery filteredQuery = new BooleanQuery();
+ filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
+ filteredQuery.add( classFilter, BooleanClause.Occur.MUST );
+ return filteredQuery;
+ }
+ }
+
private int max(int first, Hits hits) {
return maxResults == null ?
- first + hits.length() - 1 :
+ hits.length() - 1 :
maxResults + first < hits.length() ?
- first + maxResults :
+ first + maxResults - 1 :
hits.length() - 1;
}
@@ -181,6 +211,7 @@
0;
}
+ //TODO change classesAndSubclasses by side effect, which is a mismatch with the Searcher return, fix that.
private Searcher buildSearcher(LuceneEventListener listener) {
Map<Class, DocumentBuilder<Object>> builders = listener.getDocumentBuilders();
Set<Directory> directories = new HashSet<Directory>();
@@ -189,6 +220,7 @@
for ( DocumentBuilder builder : builders.values() ) {
directories.add( builder.getDirectoryProvider().getDirectory() );
}
+ classesAndSubclasses = null;
}
else {
Set<Class> involvedClasses = new HashSet<Class>( classes.length );
@@ -203,6 +235,7 @@
if ( builder == null ) throw new HibernateException( "Not a mapped entity: " + clazz );
directories.add( builder.getDirectoryProvider().getDirectory() );
}
+ classesAndSubclasses = involvedClasses;
}
//set up the searcher
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java 2006-11-01 19:07:24 UTC (rev 10677)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java 2006-11-01 21:32:11 UTC (rev 10678)
@@ -56,11 +56,57 @@
assertTrue( Hibernate.isInitialized( element ) );
s.delete( element );
}
- for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
+ for (Object element : s.createQuery( "from java.lang.Object" ).list() ) s.delete( element );
tx.commit();
s.close();
}
+ public void testFirstMax() throws Exception {
+ LuceneSession s = new LuceneSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock(1, "Seiko");
+ s.save( clock );
+ clock = new Clock( 2, "Festina");
+ s.save( clock );
+ Book book = new Book(1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah");
+ s.save(book);
+ book = new Book(2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo");
+ s.save(book);
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser("title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:Festina Or brand:Seiko" );
+ org.hibernate.Query hibQuery = s.createLuceneQuery( query, Clock.class, Book.class );
+ hibQuery.setFirstResult( 1 );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "first result no max result", 1, result.size() );
+
+ hibQuery.setFirstResult( 0 );
+ hibQuery.setMaxResults( 1 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "max result set", 1, result.size() );
+
+ hibQuery.setFirstResult( 0 );
+ hibQuery.setMaxResults( 3 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "max result out of limit", 2, result.size() );
+
+ hibQuery.setFirstResult( 2 );
+ hibQuery.setMaxResults( 3 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "first result out of limit", 0, result.size() );
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list() ) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
public void testIterator() throws Exception {
LuceneSession s = new LuceneSession( openSession() );
Transaction tx = s.beginTransaction();
@@ -93,7 +139,7 @@
s.delete( result.next() );
}
assertEquals( 2, index );
- for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
+ for (Object element : s.createQuery( "from java.lang.Object" ).list() ) s.delete( element );
tx.commit();
s.close();
}
@@ -136,7 +182,7 @@
while ( result.next() ) {
s.delete( result.get()[0] );
}
- for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
+ for (Object element : s.createQuery( "from java.lang.Object" ).list() ) s.delete( element );
tx.commit();
s.close();
}
@@ -144,6 +190,8 @@
public void testMultipleEntityPerIndex() throws Exception {
LuceneSession s = new LuceneSession( openSession() );
Transaction tx = s.beginTransaction();
+ Clock clock = new Clock(1, "Seiko");
+ s.save( clock );
Book book = new Book(1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah");
s.save(book);
AlternateBook alternateBook = new AlternateBook(1, "La chute de la petite reine a travers les yeux de Festina");
@@ -158,8 +206,30 @@
List result = hibQuery.list();
assertNotNull( result );
assertEquals( "Query with explicit class filter", 1, result.size() );
+
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createLuceneQuery( query, Clock.class, Book.class );
+ Iterator it = hibQuery.iterate();
+ assertTrue( it.hasNext() );
+ assertNotNull( it.next() );
+ assertFalse( it.hasNext() );
- query = parser.parse( "summary:Festina" );
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createLuceneQuery( query, Clock.class, Book.class );
+ ScrollableResults sr = hibQuery.scroll();
+ assertTrue( sr.first() );
+ assertNotNull( sr.get() );
+ assertFalse( sr.next() );
+ sr.close();
+
+ query = parser.parse( "summary:Festina OR brand:seiko" );
+ hibQuery = s.createLuceneQuery( query, Clock.class, Book.class );
+ hibQuery.setMaxResults( 2 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit class filter and limit", 2, result.size() );
+
+ query = parser.parse( "summary:Festina" );
hibQuery = s.createLuceneQuery( query );
result = hibQuery.list();
assertNotNull( result );
18 years, 2 months
Hibernate SVN: r10677 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x templates/doc templates/doc/entities templates/doc/tables test/org/hibernate/tool/hbm2x
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-01 14:07:24 -0500 (Wed, 01 Nov 2006)
New Revision: 10677
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/allEntity-list.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/index.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-list.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/perPackageEntity-list.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/index.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-list.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table-list.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
Log:
HBX-797 make hbm2doc use css and xhtml
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java 2006-11-01 19:07:24 UTC (rev 10677)
@@ -451,7 +451,6 @@
Map parameters = new HashMap();
parameters.put("docFile", docFile);
- parameters.put("title", "Package List");
List list = docHelper.getPackages();
//Remove All Classes
list.remove(0);
@@ -471,7 +470,6 @@
Map parameters = new HashMap();
parameters.put("docFile", docFile);
- parameters.put("title", "All Entities");
parameters.put("classList", docHelper.getClasses());
processTemplate(parameters, FTL_ENTITIES_ENTITY_LIST, file);
@@ -535,7 +533,6 @@
Map parameters = new HashMap();
parameters.put("docFile", docFile);
- parameters.put("title", "Schema List");
parameters.put("schemaList", docHelper.getSchemas() );
processTemplate(parameters, FTL_TABLES_SCHEMA_LIST, file);
@@ -551,7 +548,6 @@
Map parameters = new HashMap();
parameters.put("docFile", docFile);
- parameters.put("title", "All Tables");
parameters.put("tableList", docHelper.getTables() );
processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
@@ -569,7 +565,7 @@
Map parameters = new HashMap();
parameters.put("docFile", docFile);
- parameters.put("title", "Tables for " + schemaName);
+ parameters.put("title", schemaName);
parameters.put("tableList", docHelper.getTables(schemaName) );
processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css 2006-11-01 19:07:24 UTC (rev 10677)
@@ -2,81 +2,146 @@
* Hibernate Mapping Documentation Style Sheet
*/
-BODY {
+body
+{
+ background: white;
font-family: Arial, Helvetica, sans-serif;
- background-color: white;
font-size: 10pt;
}
-TH {
- background-color: #F4F4F4
-}
-
-A {
+a
+{
color: #003399;
}
-A:active {
+a:active
+{
color: #003399;
}
-A:visited {
+a:visited
+{
color: #888888;
}
-H1 {
- text-align: center;
+p, ul
+{
+ margin: 1em 0;
}
-H2 {
+h1
+{
text-align: center;
}
-H3 {
- text-align: left;
- font-size: 20px;
+table
+{
+ margin: 0.5em 0;
+ width: 100%;
+ border-collapse: collapse;
}
+* html table /* ie6 only */
+{
+ margin: 1em 0;
+}
-H4 {
+th, td
+{
+ border: solid 1px #CCCCCC;
+ padding: 3px;
+}
+
+th
+{
+ background: #F4F4F4;
text-align: left;
- font-size: 14px;
}
-.ListTitleFont {
- font-size: 20px;
+td a
+{
+ font-weight: bold;
}
-.MainTableHeading {
+hr
+{
+ border: none;
+ border-top: 1px solid #CCCCCC;
+}
+* html hr /* ie6 only */
+{
+ height: 1px;
+}
+
+.MainTableHeading
+{
font-size: 20px;
font-weight: bold;
}
-.HeaderBody {
- margin-top: 0;
- margin-right: 0;
- margin-left: 0;
- margin-bottom: 0;
+p.MainTableHeading
+{
+ background: #F4F4F4;
+ border: solid 1px #CCCCCC;
+ padding: 3px;
}
-.HeaderTable {
- background-color: #F4F4F4;
+.List p
+{
+ margin: 0 0 10px 0;
+}
+
+.ListTitleFont
+{
+ font-size: large;
font-weight: bold;
+ white-space: nowrap;
+}
+
+/* header */
+
+.HeaderBody
+{
+ margin: 0;
+ background: #F4F4F4;
+}
+
+.HeaderTable
+{
+ width: 100%;
+ margin: 0;
+ font-weight: bold;
text-align: center;
}
-.HeaderLink {
+.HeaderTable th, .HeaderTable td
+{
+ border: none;
+}
+
+.HeaderTable img
+{
+ border: none;
+}
+
+.HeaderLink
+{
text-decoration: none;
}
/* entity hierarchy */
-.EntityHierarchy
+ul.EntityHierarchy
{
border: solid 1px #CCCCCC;
background: #F4F4F4;
+ list-style: none;
padding: 5px;
font: bold 90% monospace;
}
+* html ul.EntityHierarchy /* ie6 only */
+{
+ margin-left: 0;
+}
.EntityHierarchy a
{
@@ -102,4 +167,4 @@
.EntityHierarchy ul ul
{
padding-left: 30px;
-}
\ No newline at end of file
+}
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/allEntity-list.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/allEntity-list.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/allEntity-list.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,30 +1,21 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity List</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity List</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body class="List">
- <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
- <TR>
- <TD NOWRAP>
- <FONT CLASS="ListTitleFont">
- ${title}
- </FONT>
- <BR>
- </TD>
- </TR>
- <TR>
- <TD>
- <#foreach class in classList>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}' TARGET="generalFrame">${class.declarationName}</A>
- <BR>
- </#foreach>
- </TD>
- </TR>
- </TABLE>
+ <p class="ListTitleFont">
+ All Entities
+ </p>
+
+ <p>
+ <#foreach class in classList>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}" target="generalFrame">${class.declarationName}</a><br/>
+ </#foreach>
+ </p>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,256 +1,256 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity Info</TITLE>
- <LINK REL ="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity Info</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H4>${class.packageName}</H4>
- <H3>Entity ${class.getShortName()}</H3>
+ <h4>
+ <#if class.packageName?length gt 0>
+ ${class.packageName}
+ <#else>
+ Default package
+ </#if>
+ </h4>
+ <h2>Entity ${class.getShortName()}</h2>
- <div class="EntityHierarchy">
- <ul>
- <li>
- <#assign superClasses=dochelper.getInheritanceHiearchy(class)>
- <#list superClasses?reverse as superClass>
- <#-- whitespace is significant here -->
- <#if superClass_index gt 0><img src="${docFileManager.getRef(docFile, docFileManager.getExtendsImageDocFile())}" alt="extended by"/></#if><a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(superClass))}">${superClass.qualifiedDeclarationName}</a>
- <ul <#if superClass_index == 0>class="first"</#if>>
- <li>
- </#list>
+ <ul class="EntityHierarchy">
+ <li>
+ <#assign superClasses=dochelper.getInheritanceHiearchy(class)>
+ <#list superClasses?reverse as superClass>
<#-- whitespace is significant here -->
- <#if class.subclass><img src="${docFileManager.getRef(docFile, docFileManager.getExtendsImageDocFile())}" alt="extended by"/></#if>${class.qualifiedDeclarationName}
- <#list superClasses as superClass>
- </li>
- </ul>
- </#list>
- </li>
- </ul>
- </div>
+ <#if superClass_index gt 0><img src="${docFileManager.getRef(docFile, docFileManager.getExtendsImageDocFile())}" alt="extended by"/></#if><a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(superClass))}">${superClass.qualifiedDeclarationName}</a>
+ <ul <#if superClass_index == 0>class="first"</#if>>
+ <li>
+ </#list>
+ <#-- whitespace is significant here -->
+ <#if class.subclass><img src="${docFileManager.getRef(docFile, docFileManager.getExtendsImageDocFile())}" alt="extended by"/></#if>${class.qualifiedDeclarationName}
+ <#list superClasses as superClass>
+ </li>
+ </ul>
+ </#list>
+ </li>
+ </ul>
+ <hr/>
+
<#if class.getMetaAsString("class-description")?has_content>
- <HR>
- <BR>
- ${class.getMetaAsString("class-description")}
- <BR>
+ <p>
+ ${class.getMetaAsString("class-description")}
+ </p>
+ <hr/>
</#if>
- <HR>
-
+
<#if class.hasIdentifierProperty()>
<#assign propertyIdentifier = class.getIdentifierProperty()>
- <P>
- <A NAME="identifier_summary"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="9" CLASS="MainTableHeading">
- Identifier Summary
- </TH>
- </TR>
- <TR>
- <TH WIDTH="14%">
- Name
- </TH>
- <TH WIDTH="14%">
- Column
- </TH>
- <TH WIDTH="14%">
- Type
- </TH>
- <TH WIDTH="58%">
- Description
- </TH>
- </TR>
- </THEAD>
+
+ <table id="identifier_summary">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="4">
+ Identifier Summary
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 14%">
+ Name
+ </th>
+ <th style="width: 14%">
+ Column
+ </th>
+ <th style="width: 14%">
+ Type
+ </th>
+ <th style="width: 58%">
+ Description
+ </th>
+ </tr>
+ </thead>
- <TBODY>
- <#if dochelper.getComponentPOJO(propertyIdentifier)?exists>
- <#assign compoclass = dochelper.getComponentPOJO(propertyIdentifier)>
- <#foreach property in compoclass.allPropertiesIterator>
- <#assign columnIterator = property.getValue().columnIterator>
- <#assign rowspan = property.getValue().getColumnSpan()>
- <TR>
- <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <A HREF='#field_summary'>
- ${property.name}
- </A>
- </TD>
-
- <#if (rowspan>0)>
- <#assign column = columnIterator.next()>
- <#if column.isFormula()>
- <TD WIDTH="14%">
-
- </TD>
- <#else>
- <TD WIDTH="14%">
- <A HREF='#property_summary'>
- ${column.getName()}
- </A>
- </TD>
- </#if>
+ <tbody>
+ <#if dochelper.getComponentPOJO(propertyIdentifier)?exists>
+ <#assign compoclass = dochelper.getComponentPOJO(propertyIdentifier)>
+ <#foreach property in compoclass.allPropertiesIterator>
+ <#assign columnIterator = property.getValue().columnIterator>
+ <#assign rowspan = property.getValue().getColumnSpan()>
+ <tr>
+ <td <#if (rowspan>0)>rowspan="${rowspan}"</#if>>
+ <a href="#field_summary">
+ ${property.name}
+ </a>
+ </td>
+
+ <#if (rowspan > 0)>
+ <#assign column = columnIterator.next()>
+ <#if column.isFormula()>
+ <td>
+
+ </td>
<#else>
- <TD WIDTH="14%">
-
- </TD>
- </#if>
-
- <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <#if dochelper.getComponentPOJO(property)?exists>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}' TARGET="generalFrame">
- ${compoclass.getJavaTypeName(property, jdk5)?html?default(" ")}
- </A>
- <#else>
+ <td>
+ <a href="#property_summary">
+ ${column.getName()}
+ </a>
+ </td>
+ </#if>
+ <#else>
+ <td>
+
+ </td>
+ </#if>
+
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ <#if dochelper.getComponentPOJO(property)?exists>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}" target="generalFrame">
${compoclass.getJavaTypeName(property, jdk5)?html?default(" ")}
- </#if>
- </TD>
-
- <TD WIDTH="44%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <#if compoclass.hasFieldJavaDoc(property)?exists>
- ${compoclass.getFieldDescription(property)?default(" ")}
- <#else>
-
- </#if>
- </TD>
- </TR>
-
- <#if (rowspan>1)>
- <#foreach column in columnIterator>
- <TR>
- <TD>
- <A HREF='#property_summary'>
- ${column.name}
- </A>
- </TD>
- </TR>
- </#foreach>
- </#if>
- </#foreach>
- <#else>
- <TR>
- <TD WIDTH="14%">
- <A HREF='#field_summary'>
- ${propertyIdentifier.name}
- </A>
- </TD>
- <TD WIDTH="14%">
- Column
- </TD>
- <TD WIDTH="14%">
- ${class.getJavaTypeName(propertyIdentifier, jdk5)?html?default(" ")}
- </TD>
- <TD WIDTH="58%">
- <#if class.hasFieldJavaDoc(propertyIdentifier)>
- ${class.getFieldDescription(propertyIdentifier)?default(" ")}
+ </a>
<#else>
+ ${compoclass.getJavaTypeName(property, jdk5)?html?default(" ")}
+ </#if>
+ </td>
+
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ <#if compoclass.hasFieldJavaDoc(property)?exists>
+ ${compoclass.getFieldDescription(property)?default(" ")}
+ <#else>
</#if>
- </TD>
- </TR>
- </#if>
- </TBODY>
- </TABLE>
- </P>
+ </td>
+ </tr>
+
+ <#if (rowspan > 1)>
+ <#foreach column in columnIterator>
+ <tr>
+ <td>
+ <a href="#property_summary">
+ ${column.name}
+ </a>
+ </td>
+ </tr>
+ </#foreach>
+ </#if>
+ </#foreach>
+ <#else>
+ <tr>
+ <td>
+ <a href="#field_summary">
+ ${propertyIdentifier.name}
+ </a>
+ </td>
+ <td>
+ Column
+ </td>
+ <td>
+ ${class.getJavaTypeName(propertyIdentifier, jdk5)?html?default(" ")}
+ </td>
+ <td>
+ <#if class.hasFieldJavaDoc(propertyIdentifier)>
+ ${class.getFieldDescription(propertyIdentifier)?default(" ")}
+ <#else>
+
+ </#if>
+ </td>
+ </tr>
+ </#if>
+ </tbody>
+ </table>
</#if>
- <P>
- <A NAME="property_summary"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="9" CLASS="MainTableHeading">
- Property Summary
- </TH>
- </TR>
- <TR>
- <TH WIDTH="14%">
- Name
- </TH>
- <TH WIDTH="14%">
- Column
- </TH>
- <TH WIDTH="14%">
- Access
- </TH>
- <TH WIDTH="14%">
- Type
- </TH>
- <TH WIDTH="44%">
- Description
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ <table id="property_summary">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="5">
+ Property Summary
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 14%">
+ Name
+ </th>
+ <th style="width: 14%">
+ Column
+ </th>
+ <th style="width: 14%">
+ Access
+ </th>
+ <th style="width: 14%">
+ Type
+ </th>
+ <th style="width: 44%">
+ Description
+ </th>
+ </tr>
+ </thead>
+ <tbody>
- <#foreach property in class.allPropertiesIterator>
- <#assign columnIterator = property.getValue().columnIterator>
- <#assign rowspan = property.getValue().getColumnSpan()>
- <TR>
- <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <A HREF='#field_summary'>
- ${property.name}
- </A>
- </TD>
+ <#foreach property in class.allPropertiesIterator>
+ <#assign columnIterator = property.getValue().columnIterator>
+ <#assign rowspan = property.getValue().getColumnSpan()>
+ <tr>
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ <a href="#field_summary">
+ ${property.name}
+ </a>
+ </td>
- <#if (rowspan>0)>
- <#assign column = columnIterator.next()>
- <#if column.isFormula()>
- <TD WIDTH="14%">
-
- </TD>
- <#else>
- <TD WIDTH="14%">
- <A HREF='#property_summary'>
- ${column.getName()}
- </A>
- </TD>
- </#if>
+ <#if (rowspan > 0)>
+ <#assign column = columnIterator.next()>
+ <#if column.isFormula()>
+ <td>
+
+ </td>
<#else>
- <TD WIDTH="14%">
-
- </TD>
+ <td>
+ <a href="#property_summary">
+ ${column.getName()}
+ </a>
+ </td>
</#if>
+ <#else>
+ <td>
+
+ </td>
+ </#if>
- <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- ${property.getPropertyAccessorName()} (<A HREF='#property_summary'>get</A> / <A HREF='#property_summary'>set</A>)
- </TD>
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ ${property.getPropertyAccessorName()} (<a href="#property_summary">get</a> / <a href="#property_summary">set</a>)
+ </td>
- <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <#if dochelper.getComponentPOJO(property)?exists>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}' TARGET="generalFrame">
- ${class.getJavaTypeName(property, jdk5)?html?default(" ")}
- </A>
- <#else>
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ <#if dochelper.getComponentPOJO(property)?exists>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}" target="generalFrame">
${class.getJavaTypeName(property, jdk5)?html?default(" ")}
- </#if>
- </TD>
+ </a>
+ <#else>
+ ${class.getJavaTypeName(property, jdk5)?html?default(" ")}
+ </#if>
+ </td>
- <TD WIDTH="44%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
- <#if class.hasFieldJavaDoc(property)>
- ${class.getFieldDescription(property)?default(" ")}
- <#else>
-
- </#if>
- </TD>
- </TR>
- <#if (rowspan>1)>
- <#foreach column in columnIterator>
- <TR>
- <TD>
- <A HREF='#property_summary'>
- ${column.name}
- </A>
- </TD>
- </TR>
- </#foreach>
- </#if>
- </#foreach>
+ <td <#if (rowspan > 0)>rowspan="${rowspan}"</#if>>
+ <#if class.hasFieldJavaDoc(property)>
+ ${class.getFieldDescription(property)?default(" ")}
+ <#else>
+
+ </#if>
+ </td>
+ </tr>
+ <#if (rowspan > 1)>
+ <#foreach column in columnIterator>
+ <tr>
+ <td>
+ <a href="#property_summary">
+ ${column.name}
+ </a>
+ </td>
+ </tr>
+ </#foreach>
+ </#if>
+ </#foreach>
- </TBODY>
- </TABLE>
- </P>
-
- </BODY>
-</HTML>
+ </tbody>
+ </table>
+
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/index.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/index.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/index.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,21 +1,23 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity Mapping Information</TITLE>
- <LINK REL ="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity Mapping Information</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
- <FRAMESET cols="20%,80%">
- <FRAMESET rows="30%,70%">
- <FRAME src="allpackages.html" name="packagesFrame" title="All Packages"/>
- <FRAME src="allentities.html" name="entitiesFrame" title="All Entities"/>
- </FRAMESET>
- <FRAME src="summary.html" name="generalFrame" title="Entity descriptions" scrolling="yes"/>
- <NOFRAMES>
- <H2>Frame Alert</H2>
- This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web browser.
- </NOFRAMES>
- </FRAMESET>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="allpackages.html" name="packagesFrame" title="All Packages"/>
+ <frame src="allentities.html" name="entitiesFrame" title="All Entities"/>
+ </frameset>
+ <frame src="summary.html" name="generalFrame" title="Entity descriptions" scrolling="yes"/>
+ <noframes>
+ <body>
+ <h2>Frame Alert</h2>
+ <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.</p>
+ </body>
+ </noframes>
+ </frameset>
-</HTML>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-list.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-list.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-list.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,32 +1,24 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Package List</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Package List</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body class="List">
- <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
- <TR>
- <TD NOWRAP>
- <FONT CLASS="ListTitleFont">
- ${title}
- </FONT>
- <BR>
- </TD>
- </TR>
- <TR>
- <TD>
- <A HREF="${docFileManager.getRef(docFile, docFileManager.getAllEntitiesDocFile())}" TARGET="entitiesFrame">all entities</A>
- <BR>
- <#foreach package in packageList>
- <A HREF="${docFileManager.getRef(docFile, docFileManager.getPackageEntityListDocFile(package))}" TARGET="entitiesFrame">${package}</A>
- <BR>
- </#foreach>
- </TD>
- </TR>
- </TABLE>
+ <p>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getAllEntitiesDocFile())}" target="entitiesFrame">All Entities</a>
+ </p>
+
+ <p class="ListTitleFont">
+ Packages
+ </p>
+ <p>
+ <#foreach package in packageList>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getPackageEntityListDocFile(package))}" target="entitiesFrame">${package}</a><br/>
+ </#foreach>
+ </p>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,43 +1,39 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity Summary</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity Summary</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H1>Hibernate Mapping Documentation</H1>
+ <h2>Package ${package}</h2>
- <H2>Package ${package}</H2>
-
- <P>
- <#if (classList.size()>0)>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
- Entities Summary
- </TH>
- </TR>
- </THEAD>
- <TBODY>
- <#foreach class in classList>
- <TR>
- <TD WIDTH="30%">
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}' TARGET="generalFrame">
- <B>${class.declarationName}</B>
- </A>
- </TD>
- <TD WIDTH="70%">
- ${class.getMetaAsString("class-description")?default(" ")}
- </TD>
- </TR>
- </#foreach>
- </TBODY>
- </TABLE>
- </#if>
- </P>
+ <#if (classList.size() > 0)>
+ <table>
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
+ Entities Summary
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <#foreach class in classList>
+ <tr>
+ <td style="width: 15%">
+ <a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}" target="generalFrame">
+ ${class.declarationName}
+ </a>
+ </td>
+ <td>
+ ${class.getMetaAsString("class-description")?default(" ")}
+ </td>
+ </tr>
+ </#foreach>
+ </tbody>
+ </table>
+ </#if>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/perPackageEntity-list.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/perPackageEntity-list.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/perPackageEntity-list.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,34 +1,24 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity List</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity List</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body class="List">
- <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
- <TR>
- <TD NOWRAP>
- <FONT CLASS="ListTitleFont">
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getPackageSummaryDocFile(title))}' TARGET="generalFrame">${title}</A>
- </FONT>
- <BR>
- </TD>
- </TR>
- <#if (classList.size()>0)>
- <TR>
- <TD>
- Entities
- <BR>
- <#foreach class in classList>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}' TARGET="generalFrame">${class.declarationName}</A>
- <BR>
- </#foreach>
- </TD>
- </TR>
- </#if>
- </TABLE>
+ <p class="ListTitleFont">
+ <a href="${docFileManager.getRef(docFile, docFileManager.getPackageSummaryDocFile(title))}" target="generalFrame">${title}</a>
+ </p>
+
+ <#if (classList.size() > 0)>
+ <p>
+ Entities<br/>
+ <#foreach class in classList>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getEntityDocFile(class))}" target="generalFrame">${class.declarationName}</a><br/>
+ </#foreach>
+ </p>
+ </#if>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,43 +1,41 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Entity Summary</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Entity Summary</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H1>Hibernate Mapping Documentation</H1>
+ <h1>Hibernate Mapping Documentation</h1>
<#if graphsGenerated>
<p>
- <img src="entitygraph.png" usemap="#entitygraph"/>
+ <img src="entitygraph.png" alt="Entity Graph" usemap="#entitygraph"/>
<map name="entitygraph">
${entitygrapharea}
</map>
</p>
</#if>
- <H2>List of Packages</H2>
-
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
+ <table>
+ <thead>
+ <tr>
+ <th class="MainTableHeading">
Packages
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach package in packageList>
- <TR>
- <TD>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getPackageSummaryDocFile(package))}' TARGET="generalFrame"><B>${package}</B></A>
- </TD>
- </TR>
+ <tr>
+ <td>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getPackageSummaryDocFile(package))}" target="generalFrame">${package}</a>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
+ </tbody>
+ </table>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,27 +1,27 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Header</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="assets/doc-style.css" TITLE="Style"/>
- </HEAD>
- <BODY CLASS="HeaderBody">
+<html>
+ <head>
+ <title>Hibernate Mappings - Header</title>
+ <link rel="stylesheet" type="text/css" href="assets/doc-style.css" title="Style"/>
+ </head>
+ <body class="HeaderBody">
- <TABLE WIDTH="100%" HEIGHT="40px" CELLPADDING="0" CELLSPACING="0" CLASS="HeaderTable">
- <TR>
- <TD WIDTH="20%"">
- <A HREF="tables/index.html" TARGET="mainFrame" CLASS="HeaderLink">TABLES</A>
- </TD>
- <TD WIDTH="20%">
- <A HREF="entities/index.html" TARGET="mainFrame" CLASS="HeaderLink">ENTITIES</A>
- </TD>
- <TD WIDTH="20%">
- <A HREF="http://www.hibernate.org/" target="_blank">
- <IMG SRC="assets/hibernate_logo.gif" BORDER="0" ALT="HIBERNATE"/>
- </A>
- </TD>
- </TR>
- </TABLE>
+ <table class="HeaderTable">
+ <tr>
+ <td style="width: 33%">
+ <a class="HeaderLink" href="tables/index.html" target="mainFrame">TABLES</a>
+ </td>
+ <td style="width: 33%">
+ <a class="HeaderLink" href="entities/index.html" target="mainFrame">ENTITIES</a>
+ </td>
+ <td style="width: 33%">
+ <a href="http://www.hibernate.org/" target="_blank">
+ <img src="assets/hibernate_logo.gif" alt="HIBERNATE"/>
+ </a>
+ </td>
+ </tr>
+ </table>
- </BODY>
-</HTML>
\ No newline at end of file
+ </body>
+</html>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,18 +1,20 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Hibernate Mapping Information</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="assets/doc-style.css" TITLE="Style"/>
- </HEAD>
+<html>
+ <head>
+ <title>Hibernate Mappings - Hibernate Mapping Information</title>
+ <link rel="stylesheet" type="text/css" href="assets/doc-style.css" title="Style"/>
+ </head>
- <FRAMESET rows="50px,80%">
- <FRAME src="header.html" name="headerFrame" title="Header"/>
- <FRAME src="entities/index.html" name="mainFrame" title="Main"/>
- <NOFRAMES>
- <H2>Frame Alert</H2>
- This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web browser.
- </NOFRAMES>
- </FRAMESET>
+ <frameset rows="50px,80%">
+ <frame src="header.html" name="headerFrame" title="Header" scrolling="no"/>
+ <frame src="entities/index.html" name="mainFrame" title="Main"/>
+ <noframes>
+ <body>
+ <h2>Frame Alert</h2>
+ <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.</p>
+ </body>
+ </noframes>
+ </frameset>
-</HTML>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/index.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/index.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/index.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,21 +1,23 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Table Mapping Information</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
+<html>
+ <head>
+ <title>Hibernate Mappings - Table Mapping Information</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
- <FRAMESET cols="20%,80%">
- <FRAMESET rows="30%,70%">
- <FRAME src="allschemas.html" name="schemasFrame" title="All Schemas"/>
- <FRAME src="alltables.html" name="tablesFrame" title="All Tables"/>
- </FRAMESET>
- <FRAME src="summary.html" name="generalFrame" title="Table descriptions" scrolling="yes"/>
- <NOFRAMES>
- <H2>Frame Alert</H2>
- This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web browser.
- </NOFRAMES>
- </FRAMESET>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="allschemas.html" name="schemasFrame" title="All Schemas"/>
+ <frame src="alltables.html" name="tablesFrame" title="All Tables"/>
+ </frameset>
+ <frame src="summary.html" name="generalFrame" title="Table descriptions" scrolling="yes"/>
+ <noframes>
+ <body>
+ <h2>Frame Alert</h2>
+ <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.</p>
+ </body>
+ </noframes>
+ </frameset>
-</HTML>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-list.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-list.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-list.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,28 +1,25 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Schema List</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Schema List</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body class="List">
- <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
- <TR>
- <TD NOWRAP>
- <FONT CLASS="ListTitleFont">
- ${title}
- </FONT>
- <BR>
- <A HREF="${docFileManager.getRef(docFile, docFileManager.getAllTablesDocFile())}" TARGET="tablesFrame">all tables</A>
- <BR>
- <#foreach schema in schemaList>
- <A HREF="${docFileManager.getRef(docFile, docFileManager.getSchemaTableListDocFile(schema))}" TARGET="tablesFrame">${schema}</A>
- <BR>
- </#foreach>
- </TD>
- </TR>
- </TABLE>
+ <p>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getAllTablesDocFile())}" target="tablesFrame">All Tables</a>
+ </p>
- </BODY>
-</HTML>
+ <p class="ListTitleFont">
+ Schemas
+ </p>
+
+ <p>
+ <#foreach schema in schemaList>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getSchemaTableListDocFile(schema))}" target="tablesFrame">${schema}</a><br/>
+ </#foreach>
+ </p>
+
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,75 +1,72 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Table Summary</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Table Summary</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H1>Hibernate Mapping Documentation</H1>
+ <h2>Schema ${schema}</h2>
- <H2>List of Tables for Schema: ${schema}</H2>
-
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
+ <table>
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
Tables
- </TH>
- </TR>
- </THEAD>
-
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach table in dochelper.tablesBySchema.get(schema)>
- <TR>
- <TD>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}' TARGET="generalFrame">
- <B>${table.name}</B>
- </A>
- </TD>
- <TD>
- <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH WIDTH="50%">
+ <tr>
+ <td>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}" target="generalFrame">
+ ${table.name}
+ </a>
+ </td>
+ <td>
+ <table>
+ <thead>
+ <tr>
+ <th style="width: 50%">
Name
- </TH>
- <TH WIDTH="30%">
+ </th>
+ <th style="width: 30%">
SQL Type
- </TH>
- <TH WIDTH="15%">
+ </th>
+ <th style="width: 15%">
Nullable
- </TH>
- <TH WIDTH="15%">
+ </th>
+ <th style="width: 15%">
Unique
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach column in table.columnIterator>
- <TR>
- <TD>
+ <tr>
+ <td>
${column.name}
- </TD>
- <TD>
+ </td>
+ <td>
${dochelper.getSQLTypeName(column)}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.nullable?string}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.unique?string}
- </TD>
- </TR>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
- </TD>
- </TR>
+ </tbody>
+ </table>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
+ </tbody>
+ </table>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,87 +1,85 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Table Summary</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Table Summary</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H1>Hibernate Mapping Documentation</H1>
+ <h1>Hibernate Mapping Documentation</h1>
<#if graphsGenerated>
<p>
- <img src="tablegraph.png" usemap="#tablegraph"/>
+ <img src="tablegraph.png" alt="Table Graph" usemap="#tablegraph"/>
<map name="tablegraph">
${tablegrapharea}
</map>
</p>
</#if>
- <H2>List of Tables by Schema</H2>
-
<#foreach schema in dochelper.tablesBySchema.keySet()>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
+ <table>
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
${schema}
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach table in dochelper.getTables(schema)>
- <TR>
- <TD>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}' TARGET="generalFrame">
- <B>${table.name}</B>
- </A>
- </TD>
- <TD>
- <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH WIDTH="50%">
+ <tr>
+ <td>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}" target="generalFrame">
+ ${table.name}
+ </a>
+ </td>
+ <td>
+ <table>
+ <thead>
+ <tr>
+ <th style="width: 50%">
Name
- </TH>
- <TH WIDTH="30%">
+ </th>
+ <th style="width: 30%">
SQL Type
- </TH>
- <TH WIDTH="15%">
+ </th>
+ <th style="width: 15%">
Nullable
- </TH>
- <TH WIDTH="15%">
+ </th>
+ <th style="width: 15%">
Unique
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach column in table.columnIterator>
- <TR>
- <TD>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}#column_detail_${column.name}' TARGET="generalFrame">
+ <tr>
+ <td>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}#column_detail_${column.name}" target="generalFrame">
${column.name}
- </A>
- </TD>
- <TD>
+ </a>
+ </td>
+ <td>
${dochelper.getSQLTypeName(column)}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.nullable?string}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.unique?string}
- </TD>
- </TR>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
- </TD>
- </TR>
+ </tbody>
+ </table>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
+ </tbody>
+ </table>
</#foreach>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table-list.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table-list.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table-list.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,26 +1,21 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Table List</TITLE>
- <LINK REL ="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Table List</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body class="List">
- <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
- <TR>
- <TD NOWRAP>
- <FONT CLASS="ListTitleFont">
- ${title}
- </FONT>
- <BR>
- <#foreach table in tableList>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}' TARGET="generalFrame">${table.name}</A>
- <BR>
- </#foreach>
- </TD>
- </TR>
- </TABLE>
+ <p class="ListTitleFont">
+ All Tables
+ </p>
+
+ <p>
+ <#foreach table in tableList>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}" target="generalFrame">${table.name}</a><br/>
+ </#foreach>
+ </p>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl 2006-11-01 19:07:24 UTC (rev 10677)
@@ -1,306 +1,289 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<HTML>
- <HEAD>
- <TITLE>Hibernate Mappings - Table Info</TITLE>
- <LINK REL="stylesheet" TYPE="text/css" HREF="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" TITLE="Style"/>
- </HEAD>
- <BODY>
+<html>
+ <head>
+ <title>Hibernate Mappings - Table Info</title>
+ <link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
+ </head>
+ <body>
- <H3>Table: ${table.name}</H3>
- <H4>Schema: ${dochelper.getQualifiedSchemaName(table)}</H4>
+ <h4>Schema ${dochelper.getQualifiedSchemaName(table)}</h4>
+ <h2>Table ${table.name}</h2>
- <p>${table.comment?if_exists}</p>
+ <#if table.comment?exists>
+ <p>${table.comment}</p>
+ </#if>
- <A NAME="column_summary"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="9" CLASS="MainTableHeading">
+ <table id="column_summary">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="7">
Column Summary
- </TH>
- </TR>
- <TR>
- <TH WIDTH="14%">
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 14%">
Name
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
SqlType
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
Length
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
Precision
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
Scale
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
Nullable
- </TH>
- <TH WIDTH="14%">
+ </th>
+ <th style="width: 14%">
Unique
- </TH>
- </TR>
- </THEAD>
- <TBODY>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
<#foreach column in table.columnIterator>
- <TR>
- <TD>
- <A HREF='#column_detail_${column.name}'>
+ <tr>
+ <td>
+ <a href="#column_detail_${column.name}">
${column.name}
- </A>
- </TD>
- <TD>
+ </a>
+ </td>
+ <td>
${dochelper.getSQLTypeName(column)}
- </TD>
- <TD ALIGN="RIGHT">
+ </td>
+ <td>
${column.length}
- </TD>
- <TD ALIGN="RIGHT">
+ </td>
+ <td>
${column.precision}
- </TD>
- <TD ALIGN="RIGHT">
+ </td>
+ <td>
${column.scale}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.nullable?string}
- </TD>
- <TD ALIGN="CENTER">
+ </td>
+ <td>
${column.unique?string}
- </TD>
- </TR>
+ </td>
+ </tr>
</#foreach>
- </TBODY>
- </TABLE>
+ </tbody>
+ </table>
- <P>
- <#-- SHOW THE PRIMARY KEY -->
- <A NAME="primary_key"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
- Primary Key
- </TH>
- </TR>
- </THEAD>
- <TBODY>
- <#if table.hasPrimaryKey()>
- <TR>
- <TD WIDTH="50%">
- <#if table.primaryKey.name?has_content>
- ${table.primaryKey.name}
- <#else>
- Name not specified
- </#if>
- </TD>
- <TD WIDTH="50%">
- <#list table.primaryKey.columnIterator() as column>
- <A HREF='#column_detail_${column.name}'>
- ${column.name}
- <BR>
- </A>
- </#list>
- </TD>
- </TR>
- <#else>
- <TR>
- <TD>
- No Primary Key
- </TD>
- </TR>
- </#if>
- </TBODY>
- </TABLE>
- </P>
+ <#-- SHOW THE PRIMARY KEY -->
+ <table id="primary_key">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
+ Primary Key
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 50%">
+ Name
+ </th>
+ <th style="width: 50%">
+ Columns
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <#if table.hasPrimaryKey()>
+ <tr>
+ <td>
+ <#if table.primaryKey.name?has_content>
+ ${table.primaryKey.name}
+ <#else>
+ Name not specified
+ </#if>
+ </td>
+ <td>
+ <#list table.primaryKey.columnIterator() as column>
+ <a href="#column_detail_${column.name}">
+ ${column.name}
+ </a>
+ </#list>
+ </td>
+ </tr>
+ <#else>
+ <tr>
+ <td>
+ No Primary Key
+ </td>
+ </tr>
+ </#if>
+ </tbody>
+ </table>
<#-- SHOW THE FOREIGN KEYS -->
<#if table.foreignKeyIterator.hasNext()>
- <P>
- <A NAME="foreign_keys"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="3" CLASS="MainTableHeading">
- Foreign Keys
- </TH>
- </TR>
- <TR>
- <TH WIDTH="33%">
- Name
- </TH>
- <TH WIDTH="33%">
- Referenced Table
- </TH>
- <TH WIDTH="33%">
- Columns
- </TH>
- </TR>
- </THEAD>
- <TBODY>
- <#foreach foreignKey in table.foreignKeyIterator>
- <TR>
- <TD>
- ${foreignKey.name?default("Name not specified")}
- </TD>
- <TD>
- <A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(foreignKey.referencedTable))}' TARGET="generalFrame">
- ${foreignKey.referencedTable.name}
- </A>
- </TD>
- <TD>
- <#foreach column in foreignKey.getColumnIterator()>
- <A HREF='#column_detail_${column.name}'>
- ${column.name}
- <BR>
- </A>
- </#foreach>
- </TD>
- </TR>
- </#foreach>
- </TBODY>
- </TABLE>
- </P>
+ <table id="foreign_keys">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="3">
+ Foreign Keys
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 33%">
+ Name
+ </th>
+ <th style="width: 33%">
+ Referenced Table
+ </th>
+ <th style="width: 33%">
+ Columns
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <#foreach foreignKey in table.foreignKeyIterator>
+ <tr>
+ <td>
+ ${foreignKey.name?default("Name not specified")}
+ </td>
+ <td>
+ <a href="${docFileManager.getRef(docFile, docFileManager.getTableDocFile(foreignKey.referencedTable))}" target="generalFrame">
+ ${foreignKey.referencedTable.name}
+ </a>
+ </td>
+ <td>
+ <#foreach column in foreignKey.getColumnIterator()>
+ <a href="#column_detail_${column.name}">
+ ${column.name}
+ </a>
+ </#foreach>
+ </td>
+ </tr>
+ </#foreach>
+ </tbody>
+ </table>
</#if>
<#-- SHOW THE UNIQUE KEYS -->
<#if table.uniqueKeyIterator.hasNext()>
- <P>
- <A NAME="unique_keys"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
- Unique Keys
- </TH>
- </TR>
- <TR>
- <TH WIDTH="50%">
- Name
- </TH>
- <TH WIDTH="50%">
- Columns
- </TH>
- </TR>
- </THEAD>
- <TBODY>
- <#foreach uniqueKey in table.getUniqueKeyIterator()>
- <TR>
- <TD>
- ${uniqueKey.name?default("Name not specified")}
- </TD>
- <TD>
- <#foreach column in uniqueKey.getColumnIterator()>
- <A HREF='#column_detail_${column.name}'>
- ${column.name}
- <BR>
- </A>
- </#foreach>
- </TD>
- </TR>
- </#foreach>
- </TBODY>
- </TABLE>
- </P>
+ <table id="unique_keys">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
+ Unique Keys
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 50%">
+ Name
+ </th>
+ <th style="width: 50%">
+ Columns
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <#foreach uniqueKey in table.getUniqueKeyIterator()>
+ <tr>
+ <td>
+ ${uniqueKey.name?default("Name not specified")}
+ </td>
+ <td>
+ <#foreach column in uniqueKey.getColumnIterator()>
+ <a href="#column_detail_${column.name}">
+ ${column.name}
+ </a>
+ </#foreach>
+ </td>
+ </tr>
+ </#foreach>
+ </tbody>
+ </table>
</#if>
<#-- SHOW THE TABLE INDEXES -->
<#if table.indexIterator.hasNext()>
- <P>
- <A NAME="indexes"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH COLSPAN="2" CLASS="MainTableHeading">
- Indexes
- </TH>
- </TR>
- <TR>
- <TH WIDTH="50%">
- Name
- </TH>
- <TH WIDTH="50%">
- Columns
- </TH>
- </TR>
- </THEAD>
- <TBODY>
- <#foreach index in table.indexIterator>
- <TR>
- <TD>
- ${index.name?default("Name not specificed")}
- </TD>
- <TD>
- <#foreach column in index.columnIterator>
- <A HREF='#column_detail_${column.name}'>
- ${column.name}
- <BR>
- </A>
- </#foreach>
- </TD>
- </TR>
- </#foreach>
- </TBODY>
- </TABLE>
- </P>
+ <table id="indexes">
+ <thead>
+ <tr>
+ <th class="MainTableHeading" colspan="2">
+ Indexes
+ </th>
+ </tr>
+ <tr>
+ <th style="width: 50%">
+ Name
+ </th>
+ <th style="width: 50%">
+ Columns
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <#foreach index in table.indexIterator>
+ <tr>
+ <td>
+ ${index.name?default("Name not specificed")}
+ </td>
+ <td>
+ <#foreach column in index.columnIterator>
+ <a href="#column_detail_${column.name}">
+ ${column.name}
+ </a>
+ </#foreach>
+ </td>
+ </tr>
+ </#foreach>
+ </tbody>
+ </table>
</#if>
<#if table.columnIterator.hasNext()>
- <P>
- <A NAME="column_detail"></A>
- <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
- <THEAD>
- <TR>
- <TH CLASS="MainTableHeading">
- Column Detail
- </TH>
- </TR>
- </THEAD>
- </TABLE>
+ <p id="column_detail" class="MainTableHeading">
+ Column Detail
+ </p>
+
+ <#foreach column in table.columnIterator>
+ <h3 id="column_detail_${column.name}">${column.name}</h3>
+
+ <ul>
+ <li>
+ <strong>Type:</strong> ${dochelper.getSQLTypeName(column)}
+ </li>
+ <li>
+ <strong>Length:</strong> ${column.length}
+ </li>
+ <li>
+ <strong>Precision:</strong> ${column.precision}
+ </li>
+ <li>
+ <strong>Scale:</strong> ${column.scale}
+ </li>
+ <li>
+ <strong>Nullable:</strong> ${column.nullable?string}
+ </li>
+ <li>
+ <strong>Unique:</strong> ${column.unique?string}
+ </li>
+ <li>
+ <strong>Comment:</strong> ${column.comment?if_exists}
+ </li>
+ </ul>
- <#foreach column in table.columnIterator>
- <A NAME='column_detail_${column.name}'></A>
- <H3>${column.name}</H3>
-
- <UL>
- <LI>
- <B>Type: </B>${dochelper.getSQLTypeName(column)}
- </LI>
- <LI>
- <B>Length: </B>${column.length}
- </LI>
- <LI>
- <B>Precision: </B>${column.precision}
- </LI>
- <LI>
- <B>Scale: </B>${column.scale}
- </LI>
- <LI>
- <B>Nullable: </B>${column.nullable?string}
- </LI>
- <LI>
- <B>Unique: </B>${column.unique?string}
- </LI>
- <LI>
- <B>Comment: </B>${column.comment?if_exists}
- </LI>
- </UL>
+ <#--
+ <H4>Mappings:</H4>
- <#--
- <H4>Mappings:</H4>
+ #foreach($property in $dochelper.getProperties($table, $column))
+ $property.persistentClass.className - $property.name
+ #end
+ -->
- #foreach($property in $dochelper.getProperties($table, $column))
- $property.persistentClass.className - $property.name
- #end
- -->
-
- <HR/>
- </#foreach>
+ <hr/>
+ </#foreach>
- </P>
</#if>
- </BODY>
-</HTML>
+ </body>
+</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-11-01 15:22:40 UTC (rev 10676)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-11-01 19:07:24 UTC (rev 10677)
@@ -66,18 +66,15 @@
assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.dot"));
assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.png"));
- /* Tidy complains about valid html 4.x
- final Tidy tidy = new Tidy();
-
-
new FileVisitor() {
protected void process(File dir) {
+ Tidy tidy = new Tidy();
if(dir.isFile() && dir.getName().endsWith( ".html" )) {
testHtml( tidy, dir );
}
}
- }.visit( getOutputDir() );*/
+ }.visit( getOutputDir() );
}
18 years, 2 months
Hibernate SVN: r10676 - branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 10:22:40 -0500 (Wed, 01 Nov 2006)
New Revision: 10676
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
Log:
style
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 14:31:16 UTC (rev 10675)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01 15:22:40 UTC (rev 10676)
@@ -38,237 +38,242 @@
*/
//implements setParameter()
public class LuceneQueryImpl extends AbstractQueryImpl {
- private static final Log log = LogFactory.getLog(LuceneQueryImpl.class);
- private org.apache.lucene.search.Query luceneQuery;
- private Class[] classes;
- private Integer firstResult;
- private Integer maxResults;
- private int resultSize;
+ private static final Log log = LogFactory.getLog( LuceneQueryImpl.class );
+ private org.apache.lucene.search.Query luceneQuery;
+ private Class[] classes;
+ private Integer firstResult;
+ private Integer maxResults;
+ private int resultSize;
- /**
- * classes must be immutable
- */
- public LuceneQueryImpl(org.apache.lucene.search.Query query, Class[] classes, SessionImplementor session, ParameterMetadata parameterMetadata) {
- //TODO handle flushMode
- super(query.toString(), null, session, parameterMetadata);
- this.luceneQuery = query;
- this.classes = classes;
- }
+ /**
+ * classes must be immutable
+ */
+ public LuceneQueryImpl(org.apache.lucene.search.Query query, Class[] classes, SessionImplementor session,
+ ParameterMetadata parameterMetadata) {
+ //TODO handle flushMode
+ super( query.toString(), null, session, parameterMetadata );
+ this.luceneQuery = query;
+ this.classes = classes;
+ }
- /**
- * Return an interator on the results.
- * Retrieve the object one by one (initialize it during the next() operation)
- */
- public Iterator iterate() throws HibernateException {
- //implement an interator which keep the id/class for each hit and get the object on demand
- //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
- //user stop using it
- //scrollable is better in this area
+ /**
+ * Return an interator on the results.
+ * Retrieve the object one by one (initialize it during the next() operation)
+ */
+ public Iterator iterate() throws HibernateException {
+ //implement an interator which keep the id/class for each hit and get the object on demand
+ //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
+ //user stop using it
+ //scrollable is better in this area
- LuceneEventListener listener = getLuceneEventListener();
- //find the directories
- Searcher searcher = buildSearcher(listener);
- Hits hits;
- try {
- hits = searcher.search(luceneQuery);
- setResultSize(hits);
- int first = first();
- int max = max(first, hits);
- EntityInfo[] entityInfos = new EntityInfo[max - first + 1];
- for (int index = first; index <= max; index++) {
- Document document = hits.doc(index);
- EntityInfo entityInfo = new EntityInfo();
- entityInfo.clazz = DocumentBuilder.getDocumentClass(document);
- //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
- entityInfo.id = DocumentBuilder.getDocumentId(listener, entityInfo.clazz, document);
- entityInfos[index - first] = entityInfo;
- }
- return new IteratorImpl(entityInfos, (Session) this.session);
- }
- catch (IOException e) {
- throw new HibernateException("Unable to query Lucene index", e);
- }
- finally {
- if (searcher != null) try {
- searcher.close();
- }
- catch (IOException e) {
- log.warn("Unable to properly close searcher during lucene query: " + getQueryString(), e);
- }
- }
- }
+ LuceneEventListener listener = getLuceneEventListener();
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ Hits hits;
+ try {
+ hits = searcher.search( luceneQuery );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ EntityInfo[] entityInfos = new EntityInfo[max - first + 1];
+ for ( int index = first; index <= max; index++ ) {
+ Document document = hits.doc( index );
+ EntityInfo entityInfo = new EntityInfo();
+ entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
+ //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
+ entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document );
+ entityInfos[index - first] = entityInfo;
+ }
+ return new IteratorImpl( entityInfos, (Session) this.session );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ if ( searcher != null ) try {
+ searcher.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
- public ScrollableResults scroll() throws HibernateException {
- //keep the searcher open until the resultset is closed
- LuceneEventListener listener = getLuceneEventListener();
- //find the directories
- Searcher searcher = buildSearcher(listener);
- Hits hits;
- try {
- hits = searcher.search(luceneQuery);
- setResultSize(hits);
- int first = first();
- int max = max(first, hits);
- return new ScrollableResultsImpl(searcher, hits, first, max, (Session) this.session, listener);
- }
- catch (IOException e) {
- try {
- if (searcher != null) searcher.close();
- }
- catch (IOException ee) {
- //we have the initial issue already
- }
- throw new HibernateException("Unable to query Lucene index", e);
- }
- }
+ public ScrollableResults scroll() throws HibernateException {
+ //keep the searcher open until the resultset is closed
+ LuceneEventListener listener = getLuceneEventListener();
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ Hits hits;
+ try {
+ hits = searcher.search( luceneQuery );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ return new ScrollableResultsImpl( searcher, hits, first, max, (Session) this.session, listener );
+ }
+ catch (IOException e) {
+ try {
+ if ( searcher != null ) searcher.close();
+ }
+ catch (IOException ee) {
+ //we have the initial issue already
+ }
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ }
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
- //TODO think about this scrollmode
- return scroll();
- }
+ public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
+ //TODO think about this scrollmode
+ return scroll();
+ }
- public List list() throws HibernateException {
- LuceneEventListener listener = getLuceneEventListener();
- //find the directories
- Searcher searcher = buildSearcher(listener);
- Hits hits;
- try {
- hits = searcher.search(luceneQuery);
- setResultSize(hits);
- int first = first();
- int max = max(first, hits);
- List result = new ArrayList(max - first + 1);
- Session sess = (Session) this.session;
- for (int index = first; index <= max; index++) {
- Document document = hits.doc(index);
- Class clazz = DocumentBuilder.getDocumentClass(document);
- //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
- Serializable id = DocumentBuilder.getDocumentId(listener, clazz, document);
- result.add(sess.load(clazz, id));
- //use load to benefit from the batch-size (but facing some proxy casting issues...
- }
- //then initialize the objects
- for (Object element : result) {
- Hibernate.initialize(element);
- }
- return result;
- }
- catch (IOException e) {
- throw new HibernateException("Unable to query Lucene index", e);
- }
- finally {
- if (searcher != null) try {
- searcher.close();
- }
- catch (IOException e) {
- log.warn("Unable to properly close searcher during lucene query: " + getQueryString(), e);
- }
- }
- }
+ public List list() throws HibernateException {
+ LuceneEventListener listener = getLuceneEventListener();
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ Hits hits;
+ try {
+ hits = searcher.search( luceneQuery );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ List result = new ArrayList( max - first + 1 );
+ Session sess = (Session) this.session;
+ for ( int index = first; index <= max; index++ ) {
+ Document document = hits.doc( index );
+ Class clazz = DocumentBuilder.getDocumentClass( document );
+ //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
+ Serializable id = DocumentBuilder.getDocumentId( listener, clazz, document );
+ result.add( sess.load( clazz, id ) );
+ //use load to benefit from the batch-size (but facing some proxy casting issues...
+ }
+ //then initialize the objects
+ for ( Object element : result ) {
+ Hibernate.initialize( element );
+ }
+ return result;
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ if ( searcher != null ) try {
+ searcher.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
- private int max(int first, Hits hits) {
- return maxResults == null ?
- first + hits.length() - 1 :
- maxResults + first < hits.length() ?
- first + maxResults :
- hits.length() - 1;
- }
+ private int max(int first, Hits hits) {
+ return maxResults == null ?
+ first + hits.length() - 1 :
+ maxResults + first < hits.length() ?
+ first + maxResults :
+ hits.length() - 1;
+ }
- private int first() {
- return firstResult != null ? firstResult : 0;
- }
+ private int first() {
+ return firstResult != null ?
+ firstResult :
+ 0;
+ }
- private Searcher buildSearcher(LuceneEventListener listener) {
- Map<Class, DocumentBuilder<Object>> builders = listener.getDocumentBuilders();
- Set<Directory> directories = new HashSet<Directory>();
- if (classes == null || classes.length == 0) {
- //no class means all classes
- for (DocumentBuilder builder : builders.values()) {
- directories.add(builder.getDirectoryProvider().getDirectory());
- }
- } else {
- Set<Class> involvedClasses = new HashSet<Class>(classes.length);
- Collections.addAll(involvedClasses, classes);
- for (Class clazz : classes) {
- DocumentBuilder builder = builders.get(clazz);
- if (builder != null) involvedClasses.addAll(builder.getMappedSubclasses());
- }
- for (Class clazz : involvedClasses) {
- DocumentBuilder builder = builders.get(clazz);
- //TODO should we rather choose a polymorphic path and allow non mapped entities
- if (builder == null) throw new HibernateException("Not a mapped entity: " + clazz);
- directories.add(builder.getDirectoryProvider().getDirectory());
- }
- }
+ private Searcher buildSearcher(LuceneEventListener listener) {
+ Map<Class, DocumentBuilder<Object>> builders = listener.getDocumentBuilders();
+ Set<Directory> directories = new HashSet<Directory>();
+ if ( classes == null || classes.length == 0 ) {
+ //no class means all classes
+ for ( DocumentBuilder builder : builders.values() ) {
+ directories.add( builder.getDirectoryProvider().getDirectory() );
+ }
+ }
+ else {
+ Set<Class> involvedClasses = new HashSet<Class>( classes.length );
+ Collections.addAll( involvedClasses, classes );
+ for ( Class clazz : classes ) {
+ DocumentBuilder builder = builders.get( clazz );
+ if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
+ }
+ for ( Class clazz : involvedClasses ) {
+ DocumentBuilder builder = builders.get( clazz );
+ //TODO should we rather choose a polymorphic path and allow non mapped entities
+ if ( builder == null ) throw new HibernateException( "Not a mapped entity: " + clazz );
+ directories.add( builder.getDirectoryProvider().getDirectory() );
+ }
+ }
- //set up the searcher
- Searcher searcher;
- int dirNbr = directories.size();
- if (dirNbr > 1) {
- try {
- IndexSearcher[] searchers = new IndexSearcher[dirNbr];
- Iterator<Directory> it = directories.iterator();
- for (int index = 0; index < dirNbr; index++) {
- searchers[index] = new IndexSearcher(it.next());
- }
- searcher = new MultiSearcher(searchers);
- }
- catch (IOException e) {
- throw new HibernateException("Unable to read Lucene directory", e);
- }
- } else {
- try {
- searcher = new IndexSearcher(directories.iterator().next());
- }
- catch (IOException e) {
- throw new HibernateException("Unable to read Lucene directory", e);
- }
- }
- return searcher;
- }
+ //set up the searcher
+ Searcher searcher;
+ int dirNbr = directories.size();
+ if ( dirNbr > 1 ) {
+ try {
+ IndexSearcher[] searchers = new IndexSearcher[dirNbr];
+ Iterator<Directory> it = directories.iterator();
+ for ( int index = 0; index < dirNbr; index++ ) {
+ searchers[index] = new IndexSearcher( it.next() );
+ }
+ searcher = new MultiSearcher( searchers );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to read Lucene directory", e );
+ }
+ }
+ else {
+ try {
+ searcher = new IndexSearcher( directories.iterator().next() );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to read Lucene directory", e );
+ }
+ }
+ return searcher;
+ }
- private void setResultSize(Hits hits) {
- resultSize = hits.length();
- }
+ private void setResultSize(Hits hits) {
+ resultSize = hits.length();
+ }
- //FIXME does it make sense
- public int resultSize() {
- return this.resultSize;
- }
+ //FIXME does it make sense
+ public int resultSize() {
+ return this.resultSize;
+ }
- public Query setFirstResult(int firstResult) {
- this.firstResult = firstResult;
- return this;
- }
+ public Query setFirstResult(int firstResult) {
+ this.firstResult = firstResult;
+ return this;
+ }
- public Query setMaxResults(int maxResults) {
- this.maxResults = maxResults;
- return this;
- }
+ public Query setMaxResults(int maxResults) {
+ this.maxResults = maxResults;
+ return this;
+ }
- private LuceneEventListener getLuceneEventListener() {
- PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
- LuceneEventListener listener = null;
- //FIXME this sucks since we mandante the event listener use
- for (PostInsertEventListener candidate : listeners) {
- if (candidate instanceof LuceneEventListener) {
- listener = (LuceneEventListener) candidate;
- break;
- }
- }
- if (listener == null) throw new HibernateException("Lucene event listener not initialized");
- return listener;
- }
+ private LuceneEventListener getLuceneEventListener() {
+ PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
+ LuceneEventListener listener = null;
+ //FIXME this sucks since we mandante the event listener use
+ for ( PostInsertEventListener candidate : listeners ) {
+ if ( candidate instanceof LuceneEventListener ) {
+ listener = (LuceneEventListener) candidate;
+ break;
+ }
+ }
+ if ( listener == null ) throw new HibernateException( "Lucene event listener not initialized" );
+ return listener;
+ }
- public int executeUpdate() throws HibernateException {
- throw new HibernateException("Not supported operation");
- }
+ public int executeUpdate() throws HibernateException {
+ throw new HibernateException( "Not supported operation" );
+ }
- public Query setLockMode(String alias, LockMode lockMode) {
- return null;
- }
+ public Query setLockMode(String alias, LockMode lockMode) {
+ return null;
+ }
- protected Map getLockModes() {
- return null;
- }
+ protected Map getLockModes() {
+ return null;
+ }
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01 14:31:16 UTC (rev 10675)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01 15:22:40 UTC (rev 10676)
@@ -46,6 +46,7 @@
this.listener = listener;
entityInfos = new EntityInfo[max - first + 1];
}
+
public boolean next() throws HibernateException {
return ++current <= max;
}
@@ -90,12 +91,12 @@
searcher.close();
}
catch (IOException e) {
- throw new HibernateException( "Unable to close Lucene searcher", e);
+ throw new HibernateException( "Unable to close Lucene searcher", e );
}
}
public Object[] get() throws HibernateException {
- if (current < first || current > max) return null; //or exception?
+ if ( current < first || current > max ) return null; //or exception?
EntityInfo info = entityInfos[current - first];
if ( info == null ) {
info = new EntityInfo();
@@ -104,14 +105,14 @@
document = hits.doc( current );
}
catch (IOException e) {
- throw new HibernateException( "Unable to read Lucene hits[" + current + "]", e);
+ throw new HibernateException( "Unable to read Lucene hits[" + current + "]", e );
}
info.clazz = DocumentBuilder.getDocumentClass( document );
//FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
info.id = DocumentBuilder.getDocumentId( listener, info.clazz, document );
entityInfos[current - first] = info;
}
- return new Object[] {
+ return new Object[]{
session.get( info.clazz, info.id )
};
}
@@ -206,7 +207,7 @@
}
public boolean setRowNumber(int rowNumber) throws HibernateException {
- if (rowNumber >= 0) {
+ if ( rowNumber >= 0 ) {
current = first + rowNumber;
}
else {
18 years, 2 months
Hibernate SVN: r10675 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x java/org/hibernate/tool/hbm2x/pojo templates/doc test/org/hibernate/tool/hbm2x
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-01 09:31:16 -0500 (Wed, 01 Nov 2006)
New Revision: 10675
Added:
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/inherit.gif
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ImportContextImpl.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Customer.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaTest.java
Log:
HBX-794 Inner-class names lose their outer-class context
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java 2006-11-01 14:31:16 UTC (rev 10675)
@@ -178,9 +178,6 @@
}
else {
String rawType = getRawTypeName( p, useGenerics, true, importContext );
- if(rawType!=null) {
- rawType = rawType.replace( '$', '.' );
- }
if(rawType==null) {
throw new IllegalStateException("getJavaTypeName *must* return a value");
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-01 14:31:16 UTC (rev 10675)
@@ -74,25 +74,16 @@
/** Return package name. Note: Does not handle inner classes */
public String getPackageName() {
- String generatedClass = getMetaAsString(MetaAttributeConstants.GENERATED_CLASS).trim();
- if(StringHelper.isEmpty(generatedClass) ) {
- generatedClass = getMappedClassName();
- }
- if(generatedClass==null) return ""; // will occur for <dynamic-component>
+ String generatedClass = getGeneratedClassName();
return StringHelper.qualifier(generatedClass.trim());
}
public String getShortName() {
- return StringHelper.unqualify(getMappedClassName());
+ return qualifyInnerClass(StringHelper.unqualify(getMappedClassName()));
}
public String getQualifiedDeclarationName() {
- String generatedName = getMetaAsString( MetaAttributeConstants.GENERATED_CLASS );
- if ( generatedName == null || generatedName.trim().length() == 0 ) {
- generatedName = getMappedClassName();
- }
-
- generatedName = generatedName.replace( '$', '.' ).trim();
+ String generatedName = qualifyInnerClass(getGeneratedClassName());
String qualifier = StringHelper.qualifier( getMappedClassName() );
if ( "".equals( qualifier ) ) {
return qualifier + "." + generatedName;
@@ -106,9 +97,24 @@
* @return unqualified classname for this class (can be changed by meta attribute "generated-class")
*/
public String getDeclarationName() {
- return StringHelper.unqualify( getQualifiedDeclarationName() );
+ return qualifyInnerClass(StringHelper.unqualify( getGeneratedClassName() ));
}
+ protected String getGeneratedClassName()
+ {
+ String generatedClass = getMetaAsString(MetaAttributeConstants.GENERATED_CLASS).trim();
+ if(StringHelper.isEmpty(generatedClass) ) {
+ generatedClass = getMappedClassName();
+ }
+ if(generatedClass==null) return ""; // will occur for <dynamic-component>
+ return generatedClass;
+ }
+
+ protected String qualifyInnerClass(String className)
+ {
+ return className.replace('$', '.');
+ }
+
protected abstract String getMappedClassName();
public String getMetaAsString(String attribute) {
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ImportContextImpl.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ImportContextImpl.java 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ImportContextImpl.java 2006-11-01 14:31:16 UTC (rev 10675)
@@ -50,7 +50,7 @@
* @return import string
*/
public String importType(String fqcn) {
- String result = fqcn;
+ String result = fqcn;
String additionalTypePart = null;
if(fqcn.indexOf('<')>=0) {
@@ -63,35 +63,38 @@
fqcn = result;
}
+ String pureFqcn = fqcn.replace( '$', '.' );
+
boolean canBeSimple = true;
String simpleName = StringHelper.unqualify(fqcn);
if(simpleNames.containsKey(simpleName)) {
String existingFqcn = (String) simpleNames.get(simpleName);
- if(existingFqcn.equals(fqcn)) {
+ if(existingFqcn.equals(pureFqcn)) {
canBeSimple = true;
} else {
canBeSimple = false;
}
} else {
canBeSimple = true;
- simpleNames.put(simpleName, fqcn);
- imports.add( fqcn );
+ simpleNames.put(simpleName, pureFqcn);
+ imports.add( pureFqcn );
}
- if ( inSamePackage(fqcn) || (imports.contains( fqcn ) && canBeSimple) ) {
+ if ( inSamePackage(fqcn) || (imports.contains( pureFqcn ) && canBeSimple) ) {
result = StringHelper.unqualify( result ); // dequalify
} else if ( inJavaLang( fqcn ) ) {
result = result.substring( "java.lang.".length() );
}
if(additionalTypePart!=null) {
- return result + additionalTypePart;
- } else {
- return result;
- }
+ result = result + additionalTypePart;
+ }
+
+ result = result.replace( '$', '.' );
+ return result;
}
public String staticImport(String fqcn, String member) {
@@ -129,7 +132,7 @@
for ( Iterator imps = imports.iterator(); imps.hasNext(); ) {
String next = (String) imps.next();
- if(isPrimitive(next) || inDefaultPackage(next) || inJavaLang(next) || inSamePackage(next)) {
+ if(isPrimitive(next) || inDefaultPackage(next) || inJavaLang(next) || inSamePackage(next)) {
// dont add automatically "imported" stuff
} else {
if(staticImports.contains(next)) {
@@ -140,6 +143,9 @@
}
}
+ if(buf.indexOf( "$" )>=0) {
+ return buf.toString();
+ }
return buf.toString();
}
}
Added: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/inherit.gif
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/inherit.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Customer.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Customer.hbm.xml 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Customer.hbm.xml 2006-11-01 14:31:16 UTC (rev 10675)
@@ -96,6 +96,11 @@
<many-to-many class="Product" />
</array>
+ <!-- hbm2java can't generate a innerclass (Test$Entry) correctly. should probably skip it as a fallback.-->
+ <!-- <component name="mapEntry" class="java.util.Map$Entry">
+ <property name="value" type="string"/>
+ <property name="key" type="string"/>
+ </component> -->
</class>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaTest.java 2006-11-01 06:55:20 UTC (rev 10674)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaTest.java 2006-11-01 14:31:16 UTC (rev 10675)
@@ -379,18 +379,45 @@
assertEquals("Entity", context.importType("org.test.Entity"));
assertEquals("org.other.test.Entity", context.importType("org.other.test.Entity"));
-
+
assertEquals("Collection<org.marvel.Hulk>", context.importType("java.util.Collection<org.marvel.Hulk>"));
assertEquals("Map<java.lang.String, org.marvel.Hulk>", context.importType("java.util.Map<java.lang.String, org.marvel.Hulk>"));
assertEquals("Collection<org.marvel.Hulk>[]", context.importType("java.util.Collection<org.marvel.Hulk>[]"));
- assertEquals("Map<java.lang.String, org.marvel.Hulk>", context.importType("java.util.Map<java.lang.String, org.marvel.Hulk>"));
+ assertEquals("Map<java.lang.String, org.marvel.Hulk>", context.importType("java.util.Map<java.lang.String, org.marvel.Hulk>"));
String string = context.generateImports();
assertTrue(string.indexOf("import org.hibernate.Session;")<0);
assertTrue(string.indexOf("import org.test.Entity;")>0);
- assertTrue("Entity can only be imported once", string.indexOf("import org.other.test.Entity;")<0);
+ assertTrue("Entity can only be imported once", string.indexOf("import org.other.test.Entity;")<0);
assertFalse(string.indexOf("<")>=0);
+ assertEquals("Outer.Entity", context.importType("org.test.Outer$Entity"));
+ assertEquals("org.other.test.Outer.Entity", context.importType("org.other.test.Outer$Entity"));
+
+ assertEquals("Collection<org.marvel.Outer.Hulk>", context.importType("java.util.Collection<org.marvel.Outer$Hulk>"));
+ assertEquals("Map<java.lang.String, org.marvel.Outer.Hulk>", context.importType("java.util.Map<java.lang.String, org.marvel.Outer$Hulk>"));
+ assertEquals("Collection<org.marvel.Outer.Hulk>[]", context.importType("java.util.Collection<org.marvel.Outer$Hulk>[]"));
+ assertEquals("Map<java.lang.String, org.marvel.Outer.Hulk>", context.importType("java.util.Map<java.lang.String, org.marvel.Outer$Hulk>"));
+
+
+ //assertEquals("Test.Entry", context.importType("org.hibernate.Test.Entry")); what should be the behavior for this ?
+ assertEquals("Test.Entry", context.importType("org.hibernate.Test$Entry"));
+
+ assertEquals("Map.Entry", context.importType("java.util.Map$Entry"));
+ assertEquals("Entry", context.importType("java.util.Map.Entry")); // we can't detect that it is the same class here unless we try an load all strings so we fall back to default class name.
+
+ assertEquals("List<java.util.Map.Entry>", context.importType( "java.util.List<java.util.Map$Entry>" ));
+ assertEquals("List<org.hibernate.Test.Entry>", context.importType( "java.util.List<org.hibernate.Test$Entry>" ));
+
+
+ string = context.generateImports();
+
+ assertTrue(string.indexOf("import java.util.Map")>=0);
+ assertTrue(string.indexOf("import java.utilMap$")<0);
+ assertTrue(string.indexOf("$")<0);
+
+
+
}
public void testEqualsHashCode() {
18 years, 2 months
Hibernate SVN: r10674 - in branches/Lucene_Integration/HibernateExt/metadata/src: java/org/hibernate/lucene/event test/org/hibernate/lucene/test test/org/hibernate/lucene/test/query
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 01:55:20 -0500 (Wed, 01 Nov 2006)
New Revision: 10674
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/FSDirectoryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/RamDirectoryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java
Log:
ANN-460 removal is not safe for multiple entities per index but querying is not yet
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -10,6 +10,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.lucene.DocumentBuilder;
@@ -76,16 +77,35 @@
}
private void remove(Class entity, Serializable id) {
- //FIXME lookup by term id and filter by test _hibernate_class
log.trace( "remove from Lucene index: " + entity + "#" + id );
DocumentBuilder builder = workspace.getDocumentBuilder( entity );
Term term = builder.getTerm( id );
IndexReader reader = workspace.getIndexReader( entity );
+ TermDocs termDocs = null;
try {
- reader.deleteDocuments( term );
+ //TODO is there a faster way?
+ //TODO include TermDocs into the workspace?
+ termDocs = reader.termDocs( term );
+ String entityName = entity.getName();
+ while ( termDocs.next() ) {
+ int docIndex = termDocs.doc();
+ if ( entityName.equals( reader.document( docIndex ).get( DocumentBuilder.CLASS_FIELDNAME ) ) ) {
+ //remove only the one of the right class
+ //loop all to remove all the matches (defensive code)
+ reader.deleteDocument( docIndex );
+ }
+ }
}
catch (Exception e) {
throw new HibernateException( "Unable to remove from Lucene index: " + entity + "#" + id, e );
}
+ finally {
+ if (termDocs != null) try {
+ termDocs.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to close termDocs properly", e);
+ }
+ }
}
}
Added: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -0,0 +1,82 @@
+//$Id: $
+package org.hibernate.lucene.test;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Lob;
+
+import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.DocumentId;
+import org.hibernate.lucene.Field;
+import org.hibernate.lucene.Store;
+import org.hibernate.lucene.Index;
+import org.hibernate.lucene.Boost;
+
+/**
+ * Example of 2 entities mapped in the same index
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index = "Documents")
+public class AlternateDocument {
+ private Long id;
+ private String title;
+ private String summary;
+ private String text;
+
+ AlternateDocument() {
+ }
+
+ public AlternateDocument(Long id, String title, String summary, String text) {
+ super();
+ this.id = id;
+ this.summary = summary;
+ this.text = text;
+ this.title = title;
+ }
+
+ @Id
+ //@Keyword(id = true)
+ @DocumentId()
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ //@Text
+ @Field( name = "alt_title", store = Store.YES, index = Index.TOKENIZED )
+ @Boost(2)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ //@Unstored(name = "Abstract")
+ @Field( name="Abstract", store = Store.NO, index = Index.TOKENIZED )
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ @Lob
+ //@Unstored
+ @Field( store = Store.NO, index = Index.TOKENIZED )
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+}
+
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/FSDirectoryTest.java (from rev 10671, branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/FSDirectoryTest.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -0,0 +1,193 @@
+//$Id: LuceneTest.java 10014 2006-06-12 09:56:27 -0700 (lun., 12 juin 2006) epbernard $
+package org.hibernate.lucene.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.hibernate.Session;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.lucene.Environment;
+import org.hibernate.lucene.store.FSDirectoryProvider;
+import org.hibernate.lucene.event.LuceneEventListener;
+
+/**
+ * @author Gavin King
+ */
+public class FSDirectoryTest extends TestCase {
+
+
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for (File file : files) {
+ if ( file.isDirectory() ) {
+ delete( file );
+ }
+ }
+ //super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ private File getBaseIndexDir() {
+ File current = new File( "." );
+ File sub = new File( current, "indextemp" );
+ return sub;
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ delete( sub );
+ }
+
+ private void delete(File sub) {
+ if ( sub.isDirectory() ) {
+ for ( File file : sub.listFiles() ) {
+ delete( file );
+ }
+ sub.delete();
+ }
+ else {
+ sub.delete();
+ }
+ }
+
+ public void testEventIntegration() throws Exception {
+
+
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+ IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ docs = reader.termDocs( new Term( "Title", "Action" ) );
+ doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "1", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ Document entity = (Document) s.get( Document.class, new Long( 1 ) );
+ entity.setSummary( "Object/relational mapping with EJB3" );
+ s.persist( new Document( "Seam in Action", "", "blah blah blah blah" ) );
+ s.getTransaction().commit();
+ s.close();
+
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 2, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "EJB3" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "Title", "Seam" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "2", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( s.createCriteria( Document.class ).uniqueResult() );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testBoost() throws Exception {
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
+ try {
+ QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
+ Query query = qp.parse( "title:Action OR Abstract:Action" );
+ Hits hits = searcher.search( query );
+ assertEquals( 2, hits.length() );
+ assertTrue( hits.score( 0 ) == 2 * hits.score( 1 ) );
+ assertEquals( "Hibernate in Action", hits.doc( 0 ).get( "title" ) );
+ }
+ finally {
+ if ( searcher != null ) searcher.close();
+ }
+
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ List list = s.createQuery( "from Document" ).list();
+ for ( Document document : (List<Document>) list ) {
+ s.delete( document );
+ }
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Document.class
+ };
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.lucene.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( "hibernate.lucene.Clock.directory_provider", FSDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ LuceneEventListener del = new LuceneEventListener();
+ cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
+ cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del} );
+ cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del} );
+ }
+
+}
+
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/MappingTest.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -1,191 +0,0 @@
-//$Id: LuceneTest.java 10014 2006-06-12 09:56:27 -0700 (lun., 12 juin 2006) epbernard $
-package org.hibernate.lucene.test;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermDocs;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.hibernate.Session;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.store.FSDirectoryProvider;
-import org.hibernate.lucene.event.LuceneEventListener;
-
-/**
- * @author Gavin King
- */
-public class MappingTest extends TestCase {
-
-
- protected void setUp() throws Exception {
- File sub = getBaseIndexDir();
- sub.mkdir();
- File[] files = sub.listFiles();
- for (File file : files) {
- if ( file.isDirectory() ) {
- delete( file );
- }
- }
- //super.setUp(); //we need a fresh session factory each time for index set up
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- }
-
- private File getBaseIndexDir() {
- File current = new File( "." );
- File sub = new File( current, "indextemp" );
- return sub;
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- File sub = getBaseIndexDir();
- delete( sub );
- }
-
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for ( File file : sub.listFiles() ) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
- public void testEventIntegration() throws Exception {
-
-
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
- IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 1, num );
- TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- docs = reader.termDocs( new Term( "Title", "Action" ) );
- doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "1", doc.getField( "id" ).stringValue() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- Document entity = (Document) s.get( Document.class, new Long( 1 ) );
- entity.setSummary( "Object/relational mapping with EJB3" );
- s.persist( new Document( "Seam in Action", "", "blah blah blah blah" ) );
- s.getTransaction().commit();
- s.close();
-
- reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 2, num );
- TermDocs docs = reader.termDocs( new Term( "Abstract", "EJB3" ) );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.delete( entity );
- s.getTransaction().commit();
- s.close();
-
- reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 1, num );
- TermDocs docs = reader.termDocs( new Term( "Title", "Seam" ) );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "2", doc.getField( "id" ).stringValue() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.delete( s.createCriteria( Document.class ).uniqueResult() );
- s.getTransaction().commit();
- s.close();
- }
-
- public void testBoost() throws Exception {
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
- );
- s.persist(
- new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
-
- IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
- try {
- QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
- Query query = qp.parse( "title:Action OR Abstract:Action" );
- Hits hits = searcher.search( query );
- assertEquals( 2, hits.length() );
- assertTrue( hits.score( 0 ) == 2 * hits.score( 1 ) );
- assertEquals( "Hibernate in Action", hits.doc( 0 ).get( "title" ) );
- }
- finally {
- if ( searcher != null ) searcher.close();
- }
-
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- List list = s.createQuery( "from Document" ).list();
- for ( Document document : (List<Document>) list ) {
- s.delete( document );
- }
- s.getTransaction().commit();
- s.close();
- }
-
- protected Class[] getMappings() {
- return new Class[]{Document.class};
- }
-
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- File sub = getBaseIndexDir();
- cfg.setProperty( "hibernate.lucene.default.indexBase", sub.getAbsolutePath() );
- cfg.setProperty( "hibernate.lucene.Clock.directory_provider", FSDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- LuceneEventListener del = new LuceneEventListener();
- cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
- cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del} );
- cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del} );
- }
-
-}
-
Added: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/RamDirectoryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/RamDirectoryTest.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/RamDirectoryTest.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -0,0 +1,71 @@
+//$Id: $
+package org.hibernate.lucene.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class RamDirectoryTest extends TestCase {
+
+ public void testMultipleEntitiesPerIndex() throws Exception {
+
+
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ Document document =
+ new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
+ s.persist(document);
+ s.flush();
+ s.persist(
+ new AlternateDocument( document.getId(), "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( 2, getDocumentNbr() );
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( s.get( AlternateDocument.class, document.getId() ) );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( 1, getDocumentNbr() );
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( s.createCriteria( Document.class ).uniqueResult() );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private int getDocumentNbr() throws Exception {
+ IndexReader reader = IndexReader.open( getDirectory( Document.class ) );
+ try {
+ return reader.numDocs();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Document.class,
+ AlternateDocument.class
+ };
+ }
+
+}
Added: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -0,0 +1,47 @@
+//$Id: $
+package org.hibernate.lucene.test.query;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.DocumentId;
+import org.hibernate.lucene.Field;
+import org.hibernate.lucene.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index="Book")
+public class AlternateBook {
+ @Id @DocumentId
+ private Integer id;
+ @Field(index = Index.TOKENIZED)
+ private String summary;
+
+
+ public AlternateBook() {
+ }
+
+ public AlternateBook(Integer id, String summary) {
+ this.id = id;
+ this.summary = summary;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -13,7 +13,7 @@
* @author Emmanuel Bernard
*/
@Entity
-@Indexed
+@Indexed(index = "Book" )
public class Book {
private Integer id;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java 2006-11-01 06:03:25 UTC (rev 10673)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java 2006-11-01 06:55:20 UTC (rev 10674)
@@ -30,7 +30,7 @@
s.save(book);
book = new Book(2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo");
s.save(book);
- tx.commit();//post commit events for lucene
+ tx.commit();
s.clear();
tx = s.beginTransaction();
QueryParser parser = new QueryParser("title", new StopAnalyzer() );
@@ -56,6 +56,7 @@
assertTrue( Hibernate.isInitialized( element ) );
s.delete( element );
}
+ for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
tx.commit();
s.close();
}
@@ -92,6 +93,7 @@
s.delete( result.next() );
}
assertEquals( 2, index );
+ for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
tx.commit();
s.close();
}
@@ -134,14 +136,48 @@
while ( result.next() ) {
s.delete( result.get()[0] );
}
+ for (Object element : s.createQuery( "from Book" ).list() ) s.delete( element );
tx.commit();
s.close();
}
+ public void testMultipleEntityPerIndex() throws Exception {
+ LuceneSession s = new LuceneSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Book book = new Book(1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah");
+ s.save(book);
+ AlternateBook alternateBook = new AlternateBook(1, "La chute de la petite reine a travers les yeux de Festina");
+ s.save(alternateBook);
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser("title", new StopAnalyzer() );
+ Query query = parser.parse( "summary:Festina" );
+ org.hibernate.Query hibQuery = s.createLuceneQuery( query, Clock.class, Book.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit class filter", 1, result.size() );
+
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createLuceneQuery( query );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with no class filter", 2, result.size() );
+ for (Object element : result) {
+ assertTrue( Hibernate.isInitialized( element ) );
+ s.delete( element );
+ }
+ for (Object element : s.createQuery( "from java.lang.Object" ).list() ) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+
protected Class[] getMappings() {
return new Class[] {
Book.class,
+ AlternateBook.class,
Clock.class
};
}
18 years, 2 months
Hibernate SVN: r10673 - branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 01:03:25 -0500 (Wed, 01 Nov 2006)
New Revision: 10673
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigDecimalBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigIntegerBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DoubleBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FloatBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IdFieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IntegerBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/LongBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/NumberBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/ParameterizedBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/Resolution.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringImplBridge.java
Log:
style
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigDecimalBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigDecimalBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigDecimalBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -1,7 +1,6 @@
//$Id: $
package org.hibernate.lucene.bridge;
-import java.math.BigInteger;
import java.math.BigDecimal;
import org.hibernate.util.StringHelper;
@@ -13,7 +12,7 @@
*/
public class BigDecimalBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new BigDecimal(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new BigDecimal( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigIntegerBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigIntegerBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigIntegerBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -7,11 +7,12 @@
/**
* Map a BigInteger element
+ *
* @author Emmanuel Bernard
*/
public class BigIntegerBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new BigInteger(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new BigInteger( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -1,25 +1,27 @@
//$Id: $
package org.hibernate.lucene.bridge;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.math.BigInteger;
-import java.math.BigDecimal;
import org.hibernate.HibernateException;
-import org.hibernate.reflection.XMember;
-import org.hibernate.reflection.XClass;
import org.hibernate.annotations.Parameter;
import org.hibernate.lucene.DateBridge;
+import org.hibernate.reflection.XClass;
+import org.hibernate.reflection.XMember;
/**
* @author Emmanuel Bernard
*/
public class BridgeFactory {
private static Map<String, FieldBridge> builtInBridges = new HashMap<String, FieldBridge>();
- private BridgeFactory() {}
+ private BridgeFactory() {
+ }
+
public static final IdFieldBridge DOUBLE = new String2IdFieldBridgeAdaptor( new DoubleBridge() );
public static final IdFieldBridge FLOAT = new String2IdFieldBridgeAdaptor( new FloatBridge() );
@@ -28,11 +30,11 @@
public static final IdFieldBridge LONG = new String2IdFieldBridgeAdaptor( new LongBridge() );
- public static final IdFieldBridge BIG_INTEGER = new String2IdFieldBridgeAdaptor( new BigIntegerBridge() );
+ public static final IdFieldBridge BIG_INTEGER = new String2IdFieldBridgeAdaptor( new BigIntegerBridge() );
- public static final IdFieldBridge BIG_DECIMAL = new String2IdFieldBridgeAdaptor( new BigDecimalBridge() );
+ public static final IdFieldBridge BIG_DECIMAL = new String2IdFieldBridgeAdaptor( new BigDecimalBridge() );
- public static final IdFieldBridge STRING = new String2IdFieldBridgeAdaptor( new StringImplBridge() );
+ public static final IdFieldBridge STRING = new String2IdFieldBridgeAdaptor( new StringImplBridge() );
public static final FieldBridge DATE_YEAR;
public static final FieldBridge DATE_MONTH;
@@ -44,18 +46,18 @@
static {
builtInBridges.put( Double.class.getName(), DOUBLE );
- builtInBridges.put( double.class.getName(), DOUBLE );
- builtInBridges.put( Float.class.getName(), FLOAT );
- builtInBridges.put( float.class.getName(), FLOAT );
- builtInBridges.put( Integer.class.getName(), INTEGER );
- builtInBridges.put( int.class.getName(), INTEGER );
- builtInBridges.put( Long.class.getName(), LONG );
- builtInBridges.put( long.class.getName(), LONG );
- builtInBridges.put( BigInteger.class.getName(), BIG_INTEGER );
- builtInBridges.put( BigDecimal.class.getName(), BIG_DECIMAL );
- builtInBridges.put( String.class.getName(), STRING );
+ builtInBridges.put( double.class.getName(), DOUBLE );
+ builtInBridges.put( Float.class.getName(), FLOAT );
+ builtInBridges.put( float.class.getName(), FLOAT );
+ builtInBridges.put( Integer.class.getName(), INTEGER );
+ builtInBridges.put( int.class.getName(), INTEGER );
+ builtInBridges.put( Long.class.getName(), LONG );
+ builtInBridges.put( long.class.getName(), LONG );
+ builtInBridges.put( BigInteger.class.getName(), BIG_INTEGER );
+ builtInBridges.put( BigDecimal.class.getName(), BIG_DECIMAL );
+ builtInBridges.put( String.class.getName(), STRING );
- DATE_YEAR = org.hibernate.lucene.bridge.DateBridge.DATE_YEAR;
+ DATE_YEAR = org.hibernate.lucene.bridge.DateBridge.DATE_YEAR;
DATE_MONTH = org.hibernate.lucene.bridge.DateBridge.DATE_MONTH;
DATE_DAY = org.hibernate.lucene.bridge.DateBridge.DATE_DAY;
DATE_HOUR = org.hibernate.lucene.bridge.DateBridge.DATE_HOUR;
@@ -68,7 +70,7 @@
public static FieldBridge guessType(XMember member) {
FieldBridge bridge = null;
org.hibernate.lucene.FieldBridge bridgeAnn = member.getAnnotation( org.hibernate.lucene.FieldBridge.class );
- if (bridgeAnn != null) {
+ if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
try {
Object instance = impl.newInstance();
@@ -87,21 +89,21 @@
}
}
catch (Exception e) {
- //TODO add classname
- throw new HibernateException("Unable to instanciate FieldBridge for " + member.getName(), e );
+ //TODO add classname
+ throw new HibernateException( "Unable to instanciate FieldBridge for " + member.getName(), e );
}
}
- else if ( member.isAnnotationPresent( DateBridge.class ) ) {
- Resolution resolution = member.getAnnotation( DateBridge.class ).value();
- bridge = org.hibernate.lucene.bridge.DateBridge.getDateField( resolution );
- }
- else {
+ else if ( member.isAnnotationPresent( DateBridge.class ) ) {
+ Resolution resolution = member.getAnnotation( DateBridge.class ).value();
+ bridge = org.hibernate.lucene.bridge.DateBridge.getDateField( resolution );
+ }
+ else {
//find in built-ins
XClass returnType = member.getType();
bridge = builtInBridges.get( returnType.getName() );
}
- //TODO add classname
- if (bridge == null) throw new HibernateException("Unable to guess FieldBridge for " + member.getName() );
+ //TODO add classname
+ if ( bridge == null ) throw new HibernateException( "Unable to guess FieldBridge for " + member.getName() );
return bridge;
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -14,7 +14,7 @@
/**
* Bridge a java.util.Date to a String, truncated to the resolution
* Date are stored GMT based
- *
+ * <p/>
* ie
* Resolution.YEAR: yyyy
* Resolution.MONTH: yyyyMM
@@ -23,30 +23,38 @@
* Resolution.MINUTE: yyyyMMddHHmm
* Resolution.SECOND: yyyyMMddHHmmss
* Resolution.MILLISECOND: yyyyMMddHHmmssSSS
- *
+ *
* @author Emmanuel Bernard
*/
public class DateBridge implements StringBridge, ParameterizedBridge {
- public static final String2FieldBridgeAdaptor DATE_YEAR = new String2FieldBridgeAdaptor( new DateBridge( Resolution.YEAR ) );
- public static final String2FieldBridgeAdaptor DATE_MONTH = new String2FieldBridgeAdaptor( new DateBridge( Resolution.MONTH ) );
- public static final String2FieldBridgeAdaptor DATE_DAY = new String2FieldBridgeAdaptor( new DateBridge( Resolution.DAY ) );
- public static final String2FieldBridgeAdaptor DATE_HOUR = new String2FieldBridgeAdaptor( new DateBridge( Resolution.HOUR ) );
- public static final String2FieldBridgeAdaptor DATE_MINUTE = new String2FieldBridgeAdaptor( new DateBridge( Resolution.MINUTE ) );
- public static final String2FieldBridgeAdaptor DATE_SECOND = new String2FieldBridgeAdaptor( new DateBridge( Resolution.SECOND ) );
- public static final String2IdFieldBridgeAdaptor DATE_MILLISECOND = new String2IdFieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
+ public static final String2FieldBridgeAdaptor DATE_YEAR =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.YEAR ) );
+ public static final String2FieldBridgeAdaptor DATE_MONTH =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.MONTH ) );
+ public static final String2FieldBridgeAdaptor DATE_DAY =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.DAY ) );
+ public static final String2FieldBridgeAdaptor DATE_HOUR =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.HOUR ) );
+ public static final String2FieldBridgeAdaptor DATE_MINUTE =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.MINUTE ) );
+ public static final String2FieldBridgeAdaptor DATE_SECOND =
+ new String2FieldBridgeAdaptor( new DateBridge( Resolution.SECOND ) );
+ public static final String2IdFieldBridgeAdaptor DATE_MILLISECOND =
+ new String2IdFieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
- DateTools.Resolution resolution;
+ DateTools.Resolution resolution;
- public DateBridge() {}
+ public DateBridge() {
+ }
- public DateBridge(Resolution resolution) {
- setResolution( resolution );
- }
+ public DateBridge(Resolution resolution) {
+ setResolution( resolution );
+ }
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- try {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ try {
return DateTools.stringToDate( stringValue );
}
catch (ParseException e) {
@@ -55,25 +63,25 @@
}
public String objectToString(Object object) {
- return object != null ?
- DateTools.dateToString( (Date) object, resolution ) :
- null;
+ return object != null ?
+ DateTools.dateToString( (Date) object, resolution ) :
+ null;
}
public void setParameterValues(Map parameters) {
- Object resolution = parameters.get( "resolution" );
- Resolution hibResolution;
- if (resolution instanceof String) {
- hibResolution = Resolution.valueOf( ( (String) resolution ).toUpperCase( Locale.ENGLISH ) );
- }
- else {
- hibResolution = (Resolution) resolution;
- }
- setResolution( hibResolution );
- }
+ Object resolution = parameters.get( "resolution" );
+ Resolution hibResolution;
+ if ( resolution instanceof String ) {
+ hibResolution = Resolution.valueOf( ( (String) resolution ).toUpperCase( Locale.ENGLISH ) );
+ }
+ else {
+ hibResolution = (Resolution) resolution;
+ }
+ setResolution( hibResolution );
+ }
- private void setResolution(Resolution hibResolution) {
- switch ( hibResolution ) {
+ private void setResolution(Resolution hibResolution) {
+ switch (hibResolution) {
case YEAR:
this.resolution = DateTools.Resolution.YEAR;
break;
@@ -99,11 +107,11 @@
throw new AssertionFailure( "Unknown Resolution: " + hibResolution );
}
- }
+ }
- public static String2FieldBridgeAdaptor getDateField(Resolution resolution) {
- switch( resolution ) {
- case YEAR:
+ public static String2FieldBridgeAdaptor getDateField(Resolution resolution) {
+ switch (resolution) {
+ case YEAR:
return DATE_YEAR;
case MONTH:
return DATE_MONTH;
@@ -119,6 +127,6 @@
return DATE_MILLISECOND;
default:
throw new AssertionFailure( "Unknown Resolution: " + resolution );
- }
- }
+ }
+ }
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DoubleBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DoubleBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DoubleBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -10,7 +10,7 @@
*/
public class DoubleBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new Double(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Double( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FieldBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FieldBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -13,11 +13,11 @@
//TODO should show Field or document?
//document is nice since I can save an object into several fields
public interface FieldBridge {
- /**
- * Manipulate the document to index the given value.
- * A common implementation is to add a Field <code>name</code> to the given document following
- * the parameters (<code>store</code>, <code>index</code>, <code>boost</code>) if the
- * <code>value></code> is not null
- */
- void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost);
+ /**
+ * Manipulate the document to index the given value.
+ * A common implementation is to add a Field <code>name</code> to the given document following
+ * the parameters (<code>store</code>, <code>index</code>, <code>boost</code>) if the
+ * <code>value></code> is not null
+ */
+ void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost);
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FloatBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FloatBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FloatBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -10,7 +10,7 @@
*/
public class FloatBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new Float(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Float( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IdFieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IdFieldBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IdFieldBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -10,20 +10,20 @@
*/
//FIXME rework the interface inheritance there are some common concepts with StringBridge
public interface IdFieldBridge extends FieldBridge {
- /**
- * build the element from the Document
- * This method is called when the bridge is used on a document id, If the Bridge is not expected to
- * support document id, this method should raise an exception
- * The return value is the Entity id
- *
- * @param name field name
- * @param document document
- */
- Object get(String name, Document document);
+ /**
+ * build the element from the Document
+ * This method is called when the bridge is used on a document id, If the Bridge is not expected to
+ * support document id, this method should raise an exception
+ * The return value is the Entity id
+ *
+ * @param name field name
+ * @param document document
+ */
+ Object get(String name, Document document);
- /**
+ /**
* convert the object representation to a String
- * The return String must not be null, it can be empty though
+ * The return String must not be null, it can be empty though
*/
String objectToString(Object object);
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IntegerBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IntegerBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IntegerBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -10,7 +10,7 @@
*/
public class IntegerBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new Integer(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Integer( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/LongBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/LongBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/LongBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -10,7 +10,7 @@
*/
public class LongBridge extends NumberBridge {
public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty(stringValue) ) return null;
- return new Long(stringValue);
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Long( stringValue );
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/NumberBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/NumberBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/NumberBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -1,17 +1,13 @@
//$Id: $
package org.hibernate.lucene.bridge;
-import java.util.Date;
-
-import org.apache.lucene.document.DateTools;
-
/**
* @author Emmanuel Bernard
*/
public abstract class NumberBridge implements StringBridge {
public String objectToString(Object object) {
- return object != null ?
- object.toString() :
- null;
+ return object != null ?
+ object.toString() :
+ null;
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/ParameterizedBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/ParameterizedBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/ParameterizedBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -9,6 +9,6 @@
* @author Emmanuel Bernard
*/
public interface ParameterizedBridge {
- //TODO inject Properties? since the annotations cannot support Object attribute?
- void setParameterValues(Map parameters);
+ //TODO inject Properties? since the annotations cannot support Object attribute?
+ void setParameterValues(Map parameters);
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/Resolution.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/Resolution.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/Resolution.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -8,7 +8,7 @@
*/
public enum Resolution {
YEAR,
- MONTH,
+ MONTH,
DAY,
HOUR,
MINUTE,
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -3,7 +3,6 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.hibernate.util.StringHelper;
/**
* Bridge to use a StringBridge as a IdFieldBridge
@@ -13,7 +12,7 @@
public class String2IdFieldBridgeAdaptor extends String2FieldBridgeAdaptor implements IdFieldBridge {
public String2IdFieldBridgeAdaptor(StringBridge stringBridge) {
- super(stringBridge);
+ super( stringBridge );
}
public String objectToString(Object object) {
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -15,7 +15,7 @@
/**
* convert the object representation to a String
- * The return String must not be null, it can be empty though
+ * The return String must not be null, it can be empty though
*/
String objectToString(Object object);
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringImplBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringImplBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringImplBridge.java 2006-11-01 06:03:25 UTC (rev 10673)
@@ -1,18 +1,17 @@
//$Id: $
package org.hibernate.lucene.bridge;
-import org.hibernate.util.StringHelper;
-
/**
* Map a string element
+ *
* @author Emmanuel Bernard
*/
public class StringImplBridge implements StringBridge {
public Object stringToObject(String stringValue) {
- return stringValue;
+ return stringValue;
}
public String objectToString(Object object) {
- return (String) object;
+ return (String) object;
}
}
18 years, 2 months
Hibernate SVN: r10672 - branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-01 00:46:08 -0500 (Wed, 01 Nov 2006)
New Revision: 10672
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
Log:
ANN-468 split of IdFieldBridge vs FieldBridge
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01 05:46:08 UTC (rev 10672)
@@ -20,19 +20,19 @@
private static Map<String, FieldBridge> builtInBridges = new HashMap<String, FieldBridge>();
private BridgeFactory() {}
- public static final FieldBridge DOUBLE = new String2FieldBridgeAdaptor( new DoubleBridge() );
+ public static final IdFieldBridge DOUBLE = new String2IdFieldBridgeAdaptor( new DoubleBridge() );
- public static final FieldBridge FLOAT = new String2FieldBridgeAdaptor( new FloatBridge() );
+ public static final IdFieldBridge FLOAT = new String2IdFieldBridgeAdaptor( new FloatBridge() );
- public static final FieldBridge INTEGER = new String2FieldBridgeAdaptor( new IntegerBridge() );
+ public static final IdFieldBridge INTEGER = new String2IdFieldBridgeAdaptor( new IntegerBridge() );
- public static final FieldBridge LONG = new String2FieldBridgeAdaptor( new LongBridge() );
+ public static final IdFieldBridge LONG = new String2IdFieldBridgeAdaptor( new LongBridge() );
- public static final FieldBridge BIG_INTEGER = new String2FieldBridgeAdaptor( new BigIntegerBridge() );
+ public static final IdFieldBridge BIG_INTEGER = new String2IdFieldBridgeAdaptor( new BigIntegerBridge() );
- public static final FieldBridge BIG_DECIMAL = new String2FieldBridgeAdaptor( new BigDecimalBridge() );
+ public static final IdFieldBridge BIG_DECIMAL = new String2IdFieldBridgeAdaptor( new BigDecimalBridge() );
- public static final FieldBridge STRING = new String2FieldBridgeAdaptor( new StringImplBridge() );
+ public static final IdFieldBridge STRING = new String2IdFieldBridgeAdaptor( new StringImplBridge() );
public static final FieldBridge DATE_YEAR;
public static final FieldBridge DATE_MONTH;
@@ -40,7 +40,7 @@
public static final FieldBridge DATE_HOUR;
public static final FieldBridge DATE_MINUTE;
public static final FieldBridge DATE_SECOND;
- public static final FieldBridge DATE_MILLISECOND;
+ public static final IdFieldBridge DATE_MILLISECOND;
static {
builtInBridges.put( Double.class.getName(), DOUBLE );
@@ -76,7 +76,7 @@
bridge = (FieldBridge) instance;
}
else if ( StringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new String2FieldBridgeAdaptor( (StringBridge) instance );
+ bridge = new String2IdFieldBridgeAdaptor( (StringBridge) instance );
}
if ( bridgeAnn.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
Map params = new HashMap( bridgeAnn.params().length );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01 05:46:08 UTC (rev 10672)
@@ -34,7 +34,7 @@
public static final String2FieldBridgeAdaptor DATE_HOUR = new String2FieldBridgeAdaptor( new DateBridge( Resolution.HOUR ) );
public static final String2FieldBridgeAdaptor DATE_MINUTE = new String2FieldBridgeAdaptor( new DateBridge( Resolution.MINUTE ) );
public static final String2FieldBridgeAdaptor DATE_SECOND = new String2FieldBridgeAdaptor( new DateBridge( Resolution.SECOND ) );
- public static final String2FieldBridgeAdaptor DATE_MILLISECOND = new String2FieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
+ public static final String2IdFieldBridgeAdaptor DATE_MILLISECOND = new String2IdFieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
DateTools.Resolution resolution;
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01 05:46:08 UTC (rev 10672)
@@ -1,41 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.bridge;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bridge to use a Java2String as a Java2Field
- *
- * @author Emmanuel Bernard
- */
-//FIXME all String2FieldBridgeAdaptor are not IdFieldBridge
-public class String2FieldBridgeAdaptor implements FieldBridge, IdFieldBridge {
-
- private StringBridge stringBridge;
-
- public String2FieldBridgeAdaptor(StringBridge stringBridge) {
- this.stringBridge = stringBridge;
- }
- public Object get(String name, Document document) {
- Field field = document.getField( name );
- return stringBridge.stringToObject( field.stringValue() );
- }
-
- public String objectToString(Object object) {
- return stringBridge.objectToString( object );
- }
-
- public void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost) {
- String indexedString = stringBridge.objectToString(value);
- //Do not add fields on empty strings, seems a sensible default in most situations
- if ( StringHelper.isNotEmpty( indexedString ) ) {
- Field field = new Field(name, indexedString, store, index);
- if (boost != null) field.setBoost( boost );
- document.add( field );
- }
- }
-
-
-}
Added: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01 04:27:26 UTC (rev 10671)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01 05:46:08 UTC (rev 10672)
@@ -0,0 +1,30 @@
+//$Id: $
+package org.hibernate.lucene.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge to use a StringBridge as a FieldBridge
+ *
+ * @author Emmanuel Bernard
+ */
+public class String2FieldBridgeAdaptor implements FieldBridge {
+ protected StringBridge stringBridge;
+
+ public String2FieldBridgeAdaptor(StringBridge stringBridge) {
+ this.stringBridge = stringBridge;
+ }
+
+ public void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost) {
+ String indexedString = stringBridge.objectToString( value );
+ //Do not add fields on empty strings, seems a sensible default in most situations
+ if ( StringHelper.isNotEmpty( indexedString ) ) {
+ Field field = new Field( name, indexedString, store, index );
+ if ( boost != null ) field.setBoost( boost );
+ document.add( field );
+ }
+ }
+
+}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java (from rev 10611, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-10-18 22:09:34 UTC (rev 10611)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java 2006-11-01 05:46:08 UTC (rev 10672)
@@ -0,0 +1,27 @@
+//$Id: $
+package org.hibernate.lucene.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge to use a StringBridge as a IdFieldBridge
+ *
+ * @author Emmanuel Bernard
+ */
+public class String2IdFieldBridgeAdaptor extends String2FieldBridgeAdaptor implements IdFieldBridge {
+
+ public String2IdFieldBridgeAdaptor(StringBridge stringBridge) {
+ super(stringBridge);
+ }
+
+ public String objectToString(Object object) {
+ return stringBridge.objectToString( object );
+ }
+
+ public Object get(String name, Document document) {
+ Field field = document.getField( name );
+ return stringBridge.stringToObject( field.stringValue() );
+ }
+}
18 years, 2 months