01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.annotations;
18:
19: import java.lang.annotation.ElementType;
20: import java.lang.annotation.Retention;
21: import java.lang.annotation.RetentionPolicy;
22: import java.lang.annotation.Target;
23:
24: /**
25: * Specifies a searchable reference on property or field of the {@link Searchable} class.
26: * <p/>
27: * A searchable reference is a class field/property that reference another class, and the
28: * relationship need to be stored by Compass so it can be traversed when getting the class
29: * from the index.
30: * <p/>
31: * Compass will end up saving only the ids of the referenced class in the search engine index.
32: * <p/>
33: * The searchalbe reference can annotate a {@link java.util.Collection} type field/property,
34: * supporting either {@link java.util.List} or {@link java.util.Set}. The searchable refrence
35: * will try and automatically identify the element type using generics, but if the collection
36: * is not defined with generics, {@link #refAlias()} should be used to reference the referenced
37: * searchable class mapping definitions.
38: * <p/>
39: * The searchable compoent can annotate an array as well, with the array element type used for
40: * refernced searchable class mapping definitions.
41: * <p/>
42: * The refence mapping can have a "shadow" component mapping associated with it, if specifing
43: * the {@link #refComponentAlias()}.
44: *
45: * @author kimchy
46: */
47: @Target({ElementType.METHOD,ElementType.FIELD})
48: @Retention(RetentionPolicy.RUNTIME)
49: public @interface SearchableReference {
50:
51: /**
52: * The reference alias that points to the searchable class (either defined using
53: * annotations or xml). Not required since most of the times it can be automatically
54: * detected.
55: */
56: String refAlias() default "";
57:
58: /**
59: * Specifies a reference to a searchable component that will be used
60: * to embed some of the referenced class searchable content into the
61: * field/property searchable class.
62: */
63: String refComponentAlias() default "";
64:
65: /**
66: * The operations that will cascade to the target association. Defaults to no operations
67: * being cascaded.
68: */
69: Cascade[] cascade() default {};
70:
71: /**
72: * The conveter lookup name that will convert the {@link org.compass.core.mapping.osem.ReferenceMapping}.
73: * Defaults to compass own intenral {@link org.compass.core.converter.mapping.osem.ReferenceMappingConverter}.
74: */
75: String converter() default "";
76:
77: /**
78: * The property accessor that will be fetch and write the property value.
79: * <p/>
80: * It is automatically set based on where the annotation is used, but can be
81: * explicitly set. Compass also supports custom property accessors, registered
82: * under a custom name, which can then be used here as well.
83: */
84: String accessor() default "";
85:
86: }
|