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.jpa.entities;
018:
019: import org.compass.gps.device.jpa.queryprovider.DefaultJpaQueryProvider;
020: import org.compass.gps.device.jpa.queryprovider.JpaQueryProvider;
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.jpa.JpaGpsDevice}
025: * during the indexing process.
026: *
027: * @author kimchy
028: * @see JpaEntitiesLocator
029: */
030: public class EntityInformation implements IndexEntity {
031:
032: private Class<?> clazz;
033:
034: private String name;
035:
036: private JpaQueryProvider queryProvider;
037:
038: private String[] subIndexes;
039:
040: public EntityInformation(Class<?> clazz, String name,
041: String[] subIndexes) {
042: this (clazz, name, new DefaultJpaQueryProvider(clazz, name),
043: subIndexes);
044: }
045:
046: public EntityInformation(Class<?> clazz, String name,
047: String selectQuery, String[] subIndexes) {
048: this (clazz, name, new DefaultJpaQueryProvider(selectQuery),
049: subIndexes);
050: }
051:
052: public EntityInformation(Class<?> clazz, String name,
053: JpaQueryProvider queryProvider, String[] subIndexes) {
054: this .clazz = clazz;
055: this .name = name;
056: this .queryProvider = queryProvider;
057: this .subIndexes = subIndexes;
058: }
059:
060: /**
061: * Returns the entity class associated with the entity
062: */
063: public Class<?> getEntityClass() {
064: return clazz;
065: }
066:
067: /**
068: * Returns the entity name
069: */
070: public String getName() {
071: return name;
072: }
073:
074: /**
075: * Sets a string based select query. Uses {@link org.compass.gps.device.jpa.queryprovider.DefaultJpaQueryProvider}
076: * based on the string query.
077: */
078: public void setSelectQuery(String selectQuery) {
079: this .queryProvider = new DefaultJpaQueryProvider(selectQuery);
080: }
081:
082: /**
083: * Sets a query provider. Responsible during indexing time to create
084: * a query for the given entity that will be used to query the database
085: * for indexing.
086: */
087: public void setQueryProvider(JpaQueryProvider queryProvider) {
088: this .queryProvider = queryProvider;
089: }
090:
091: /**
092: * Gets a query provider. Responsible during indexing time to create
093: * a query for the given entity that will be used to query the database
094: * for indexing.
095: */
096: public JpaQueryProvider getQueryProvider() {
097: return this .queryProvider;
098: }
099:
100: /**
101: * Returns a list of the sub indexes this indexable
102: * content the index entity represents is going to
103: * be indexed into. Used for parallel indexing.
104: */
105: public String[] getSubIndexes() {
106: return subIndexes;
107: }
108: }
|