001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.gps.device.hibernate.entities;
018:
019: import org.compass.gps.device.hibernate.DefaultHibernateQueryProvider;
020: import org.compass.gps.device.hibernate.HibernateQueryProvider;
021: import org.compass.gps.device.support.parallel.IndexEntity;
022:
023: /**
024: * A general Entity information to be used by the {@link org.compass.gps.device.hibernate.HibernateGpsDevice}
025: * during the indexing process.
026: *
027: * @author kimchy
028: */
029: public class EntityInformation implements IndexEntity {
030:
031: private Class clazz;
032:
033: private String name;
034:
035: private HibernateQueryProvider queryProvider;
036:
037: private String[] subIndexes;
038:
039: public EntityInformation(Class clazz, String name,
040: String[] subIndexes) {
041: this (clazz, name,
042: new DefaultHibernateQueryProvider(clazz, name),
043: subIndexes);
044: }
045:
046: public EntityInformation(Class clazz, String name,
047: String selectQuery, String[] subIndexes) {
048: this (clazz, name,
049: new DefaultHibernateQueryProvider(selectQuery),
050: subIndexes);
051: }
052:
053: public EntityInformation(Class clazz, String name,
054: HibernateQueryProvider queryProvider, String[] subIndexes) {
055: this .clazz = clazz;
056: this .name = name;
057: this .queryProvider = queryProvider;
058: this .subIndexes = subIndexes;
059: }
060:
061: /**
062: * Returns the entity class associated with the entity
063: */
064: public Class getEntityClass() {
065: return clazz;
066: }
067:
068: /**
069: * Returns the entity name
070: */
071: public String getName() {
072: return name;
073: }
074:
075: /**
076: * Sets a string based select query. Uses {@link org.compass.gps.device.hibernate.DefaultHibernateQueryProvider}
077: * based on the string query.
078: */
079: public void setSelectQuery(String selectQuery) {
080: this .queryProvider = new DefaultHibernateQueryProvider(
081: selectQuery);
082: }
083:
084: /**
085: * Sets a query provider. Responsible during indexing time to create
086: * a query for the given entity that will be used to query the database
087: * for indexing.
088: */
089: public void setQueryProvider(HibernateQueryProvider queryProvider) {
090: this .queryProvider = queryProvider;
091: }
092:
093: /**
094: * Gets a query provider. Responsible during indexing time to create
095: * a query for the given entity that will be used to query the database
096: * for indexing.
097: */
098: public HibernateQueryProvider getQueryProvider() {
099: return this .queryProvider;
100: }
101:
102: /**
103: * Returns a list of the sub indexes this indexable
104: * content the index entity represents is going to
105: * be indexed into. Used for parallel indexing.
106: */
107: public String[] getSubIndexes() {
108: return subIndexes;
109: }
110: }
|